home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / U-Z / VideoToolbox 4.95.sit / VideoToolbox / VideoToolboxSources / Luminance.c < prev    next >
MacBinary  |  1995-04-01  |  43.0 KB  |  [TEXT/MMCC]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sat Apr 1 16:57:26 1995, modified Sat Apr 1 16:57:26 1995, creator 'MMCC', type ASCII, 40644 bytes "Luminance.c" , at 0x9f44 3132 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MMCC]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 4c 75 6d 69 6e 61 | 6e 63 65 2e 63 00 00 00 |..Lumina|nce.c...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 4d 43 | 43 00 00 00 00 00 00 00 |.TEXTMMC|C.......|
|00000050| 00 00 00 00 00 9e c4 00 | 00 0c 3c ab a3 7c c6 ab |........|..<..|..|
|00000060| a3 7c c6 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.|......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 3f cd 00 00 |........|....?...|
|00000080| 2f 2a 0d 4c 75 6d 69 6e | 61 6e 63 65 2e 63 0d 53 |/*.Lumin|ance.c.S|
|00000090| 65 65 20 4c 75 6d 69 6e | 61 6e 63 65 2e 68 20 66 |ee Lumin|ance.h f|
|000000a0| 6f 72 20 70 72 6f 74 6f | 74 79 70 65 73 2e 0d 53 |or proto|types..S|
|000000b0| 65 65 20 4c 75 6d 69 6e | 61 6e 63 65 2e 6e 6f 74 |ee Lumin|ance.not|
|000000c0| 65 20 66 6f 72 20 65 78 | 70 6c 61 6e 61 74 69 6f |e for ex|planatio|
|000000d0| 6e 2e 0d 41 6c 73 6f 20 | 73 65 65 3a 0d 44 2e 47 |n..Also |see:.D.G|
|000000e0| 2e 20 50 65 6c 6c 69 20 | 61 6e 64 20 4c 2e 20 5a |. Pelli |and L. Z|
|000000f0| 68 61 6e 67 20 28 31 39 | 39 31 29 20 41 63 63 75 |hang (19|91) Accu|
|00000100| 72 61 74 65 20 63 6f 6e | 74 72 6f 6c 20 6f 66 20 |rate con|trol of |
|00000110| 63 6f 6e 74 72 61 73 74 | 20 6f 6e 20 6d 69 63 72 |contrast| on micr|
|00000120| 6f 63 6f 6d 70 75 74 65 | 72 20 64 69 73 70 6c 61 |ocompute|r displa|
|00000130| 79 73 2e 20 0d 56 69 73 | 69 6f 6e 20 52 65 73 65 |ys. .Vis|ion Rese|
|00000140| 61 72 63 68 2c 20 33 31 | 3a 31 33 33 37 2d 31 33 |arch, 31|:1337-13|
|00000150| 36 30 2e 0d 0d 43 6f 70 | 79 72 69 67 68 74 20 28 |60...Cop|yright (|
|00000160| 63 29 20 31 39 38 39 2d | 31 39 39 35 20 44 65 6e |c) 1989-|1995 Den|
|00000170| 69 73 20 47 2e 20 50 65 | 6c 6c 69 2e 20 54 68 69 |is G. Pe|lli. Thi|
|00000180| 73 20 73 6f 66 74 77 61 | 72 65 20 69 73 20 66 72 |s softwa|re is fr|
|00000190| 65 65 3b 20 79 6f 75 20 | 6d 61 79 20 75 73 65 20 |ee; you |may use |
|000001a0| 69 74 20 69 6e 0d 79 6f | 75 72 20 72 65 73 65 61 |it in.yo|ur resea|
|000001b0| 72 63 68 20 61 6e 64 20 | 67 69 76 65 20 69 74 20 |rch and |give it |
|000001c0| 61 77 61 79 20 74 6f 20 | 6f 74 68 65 72 73 2c 20 |away to |others, |
|000001d0| 77 69 74 68 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |with the| followi|
|000001e0| 6e 67 20 72 65 73 74 72 | 69 63 74 69 6f 6e 73 2e |ng restr|ictions.|
|000001f0| 20 41 6e 79 0d 63 6f 70 | 79 20 79 6f 75 20 67 69 | Any.cop|y you gi|
|00000200| 76 65 20 61 77 61 79 20 | 6d 75 73 74 20 69 6e 63 |ve away |must inc|
|00000210| 6c 75 64 65 20 74 68 69 | 73 20 70 61 72 61 67 72 |lude thi|s paragr|
|00000220| 61 70 68 2c 20 75 6e 6d | 6f 64 69 66 69 65 64 2c |aph, unm|odified,|
|00000230| 20 61 6e 64 2c 20 69 66 | 20 79 6f 75 20 68 61 76 | and, if| you hav|
|00000240| 65 0d 6d 61 64 65 20 61 | 6e 79 20 63 68 61 6e 67 |e.made a|ny chang|
|00000250| 65 73 20 74 6f 20 74 68 | 65 20 72 65 73 74 20 6f |es to th|e rest o|
|00000260| 66 20 74 68 65 20 66 69 | 6c 65 2c 20 6d 75 73 74 |f the fi|le, must|
|00000270| 20 69 6e 63 6c 75 64 65 | 20 61 20 6e 6f 74 65 2c | include| a note,|
|00000280| 20 61 64 64 65 64 20 74 | 6f 20 48 49 53 54 4f 52 | added t|o HISTOR|
|00000290| 59 0d 62 65 6c 6f 77 2c | 20 67 69 76 69 6e 67 20 |Y.below,| giving |
|000002a0| 79 6f 75 72 20 6e 61 6d | 65 2c 20 74 68 65 20 64 |your nam|e, the d|
|000002b0| 61 74 65 2c 20 61 6e 64 | 20 61 20 64 65 73 63 72 |ate, and| a descr|
|000002c0| 69 70 74 69 6f 6e 20 6f | 66 20 74 68 65 20 63 68 |iption o|f the ch|
|000002d0| 61 6e 67 65 73 2e 20 54 | 68 69 73 0d 73 6f 66 74 |anges. T|his.soft|
|000002e0| 77 61 72 65 20 6d 61 79 | 20 6e 6f 74 20 62 65 20 |ware may| not be |
|000002f0| 73 6f 6c 64 2c 20 77 68 | 65 74 68 65 72 20 69 6e |sold, wh|ether in|
|00000300| 20 73 6f 75 72 63 65 20 | 6f 72 20 63 6f 6d 70 69 | source |or compi|
|00000310| 6c 65 64 20 66 6f 72 6d | 2c 20 77 69 74 68 6f 75 |led form|, withou|
|00000320| 74 20 6d 79 0d 70 65 72 | 6d 69 73 73 69 6f 6e 2e |t my.per|mission.|
|00000330| 20 49 20 68 6f 70 65 20 | 79 6f 75 20 77 69 6c 6c | I hope |you will|
|00000340| 20 66 69 6e 64 20 74 68 | 69 73 20 73 6f 66 74 77 | find th|is softw|
|00000350| 61 72 65 20 75 73 65 66 | 75 6c 2c 20 62 75 74 20 |are usef|ul, but |
|00000360| 49 20 63 61 6e 27 74 20 | 70 72 6f 6d 69 73 65 20 |I can't |promise |
|00000370| 74 68 61 74 0d 69 74 20 | 77 69 6c 6c 20 77 6f 72 |that.it |will wor|
|00000380| 6b 20 66 6f 72 20 79 6f | 75 2c 20 61 6e 64 20 61 |k for yo|u, and a|
|00000390| 6d 20 6e 6f 74 20 6f 66 | 66 65 72 69 6e 67 20 61 |m not of|fering a|
|000003a0| 6e 79 20 73 75 70 70 6f | 72 74 2e 20 54 68 61 74 |ny suppo|rt. That|
|000003b0| 27 73 20 77 68 79 20 69 | 74 27 73 20 66 72 65 65 |'s why i|t's free|
|000003c0| 2e 20 49 0d 77 6f 75 6c | 64 20 61 70 70 72 65 63 |. I.woul|d apprec|
|000003d0| 69 61 74 65 20 72 65 70 | 6f 72 74 73 20 6f 66 20 |iate rep|orts of |
|000003e0| 62 75 67 73 20 61 6e 64 | 20 69 6d 70 72 6f 76 65 |bugs and| improve|
|000003f0| 6d 65 6e 74 73 2e 0d 0d | 44 65 6e 69 73 20 47 2e |ments...|Denis G.|
|00000400| 20 50 65 6c 6c 69 2c 20 | 50 68 2e 44 2e 0d 64 65 | Pelli, |Ph.D..de|
|00000410| 6e 69 73 40 78 70 2e 70 | 73 79 63 68 2e 6e 79 75 |nis@xp.p|sych.nyu|
|00000420| 2e 65 64 75 0d 0d 28 75 | 6e 74 69 6c 20 4a 75 6e |.edu..(u|ntil Jun|
|00000430| 65 2c 20 31 39 39 35 29 | 0d 49 6e 73 74 69 74 75 |e, 1995)|.Institu|
|00000440| 74 65 20 66 6f 72 20 53 | 65 6e 73 6f 72 79 20 52 |te for S|ensory R|
|00000450| 65 73 65 61 72 63 68 0d | 53 79 72 61 63 75 73 65 |esearch.|Syracuse|
|00000460| 20 55 6e 69 76 65 72 73 | 69 74 79 0d 53 79 72 61 | Univers|ity.Syra|
|00000470| 63 75 73 65 2c 20 4e 59 | 20 31 33 32 34 34 2d 35 |cuse, NY| 13244-5|
|00000480| 32 39 30 0d 0d 28 61 66 | 74 65 72 20 4a 75 6e 65 |290..(af|ter June|
|00000490| 2c 20 31 39 39 35 29 0d | 44 65 70 61 72 74 6d 65 |, 1995).|Departme|
|000004a0| 6e 74 20 6f 66 20 50 73 | 79 63 68 6f 6c 6f 67 79 |nt of Ps|ychology|
|000004b0| 0d 4e 65 77 20 59 6f 72 | 6b 20 55 6e 69 76 65 72 |.New Yor|k Univer|
|000004c0| 73 69 74 79 0d 36 20 57 | 61 73 68 69 6e 67 74 6f |sity.6 W|ashingto|
|000004d0| 6e 20 50 6c 61 63 65 0d | 4e 65 77 20 59 6f 72 6b |n Place.|New York|
|000004e0| 2c 20 4e 59 20 31 30 30 | 30 33 0d 0d 48 49 53 54 |, NY 100|03..HIST|
|000004f0| 4f 52 59 3a 0d 0d 34 2f | 32 34 2f 38 39 20 64 67 |ORY:..4/|24/89 dg|
|00000500| 70 20 66 69 72 73 74 20 | 77 6f 72 6b 69 6e 67 20 |p first |working |
|00000510| 76 65 72 73 69 6f 6e 2e | 0d 34 2f 32 38 2f 38 39 |version.|.4/28/89|
|00000520| 20 64 67 70 20 61 64 64 | 65 64 20 64 65 76 69 63 | dgp add|ed devic|
|00000530| 65 20 61 72 67 75 6d 65 | 6e 74 2e 0d 36 2f 32 33 |e argume|nt..6/23|
|00000540| 2f 38 39 20 64 67 70 20 | 61 64 64 65 64 20 73 75 |/89 dgp |added su|
|00000550| 70 70 6f 72 74 20 66 6f | 72 20 61 20 76 69 64 65 |pport fo|r a vide|
|00000560| 6f 20 61 74 74 65 6e 75 | 61 74 6f 72 20 74 68 61 |o attenu|ator tha|
|00000570| 74 20 68 61 73 20 75 6e | 65 71 75 61 6c 20 67 61 |t has un|equal ga|
|00000580| 69 6e 20 69 6e 20 74 68 | 65 20 74 68 72 65 65 0d |in in th|e three.|
|00000590| 09 09 09 63 68 61 6e 6e | 65 6c 73 2e 20 41 64 64 |...chann|els. Add|
|000005a0| 65 64 20 4c 6f 61 64 43 | 6c 75 74 28 29 20 61 6e |ed LoadC|lut() an|
|000005b0| 64 20 4c 75 6d 69 6e 61 | 6e 63 65 43 6c 75 74 28 |d Lumina|nceClut(|
|000005c0| 29 20 72 6f 75 74 69 6e | 65 73 2e 0d 37 2f 33 30 |) routin|es..7/30|
|000005d0| 2f 38 39 20 64 67 70 20 | 72 65 70 6c 61 63 65 64 |/89 dgp |replaced|
|000005e0| 20 63 61 6c 6c 20 74 6f | 20 53 65 74 45 6e 74 72 | call to| SetEntr|
|000005f0| 69 65 73 20 28 77 68 69 | 63 68 20 63 61 6c 6c 73 |ies (whi|ch calls|
|00000600| 20 74 68 65 20 43 6f 6c | 6f 72 20 4d 61 6e 61 67 | the Col|or Manag|
|00000610| 65 72 29 20 62 79 20 61 | 20 63 61 6c 6c 0d 09 09 |er) by a| call...|
|00000620| 09 74 6f 20 47 44 53 65 | 74 45 6e 74 72 69 65 73 |.to GDSe|tEntries|
|00000630| 20 28 77 68 69 63 68 20 | 63 61 6c 6c 73 20 74 68 | (which |calls th|
|00000640| 65 20 64 65 76 69 63 65 | 20 64 72 69 76 65 72 29 |e device| driver)|
|00000650| 2e 0d 38 2f 31 30 2f 38 | 39 20 64 67 70 20 66 69 |..8/10/8|9 dgp fi|
|00000660| 78 65 64 20 62 75 67 73 | 2e 0d 38 2f 31 33 2f 38 |xed bugs|..8/13/8|
|00000670| 39 20 64 67 70 20 72 65 | 77 72 6f 74 65 20 4c 54 |9 dgp re|wrote LT|
|00000680| 6f 56 28 29 20 74 6f 20 | 75 73 65 20 6e 74 68 20 |oV() to |use nth |
|00000690| 6f 72 64 65 72 20 70 6f | 6c 79 6e 6f 6d 69 61 6c |order po|lynomial|
|000006a0| 2e 20 42 72 6f 6b 65 20 | 75 70 20 4c 69 6e 65 61 |. Broke |up Linea|
|000006b0| 72 69 7a 65 43 6c 75 74 | 20 69 6e 74 6f 0d 09 09 |rizeClut| into...|
|000006c0| 09 74 68 72 65 65 20 72 | 6f 75 74 69 6e 65 73 2d |.three r|outines-|
|000006d0| 2d 53 65 74 4c 75 6d 69 | 6e 61 6e 63 65 52 61 6e |-SetLumi|nanceRan|
|000006e0| 67 65 2c 20 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 |ge, SetL|uminance|
|000006f0| 2c 20 61 6e 64 20 53 65 | 74 4c 75 6d 69 6e 61 6e |, and Se|tLuminan|
|00000700| 63 65 73 2d 2d 74 68 65 | 0d 09 09 09 6c 61 73 74 |ces--the|....last|
|00000710| 20 6f 66 20 77 68 69 63 | 68 20 69 73 20 65 71 75 | of whic|h is equ|
|00000720| 69 76 61 6c 65 6e 74 20 | 74 6f 20 74 68 65 20 6f |ivalent |to the o|
|00000730| 6c 64 20 4c 69 6e 65 61 | 72 69 7a 65 43 6c 75 74 |ld Linea|rizeClut|
|00000740| 2e 0d 38 2f 31 36 2f 38 | 39 09 64 67 70 09 41 66 |..8/16/8|9.dgp.Af|
|00000750| 74 65 72 20 72 65 61 64 | 69 6e 67 20 74 68 65 20 |ter read|ing the |
|00000760| 42 72 6f 6f 6b 74 72 65 | 65 20 44 41 43 20 6d 61 |Brooktre|e DAC ma|
|00000770| 6e 75 61 6c 20 49 20 63 | 68 61 6e 67 65 64 20 74 |nual I c|hanged t|
|00000780| 68 65 20 64 6f 63 75 6d | 65 6e 74 61 74 69 6f 6e |he docum|entation|
|00000790| 20 61 6e 64 0d 09 09 09 | 69 6e 63 72 65 61 73 65 | and....|increase|
|000007a0| 64 20 74 6f 6c 65 72 61 | 6e 63 65 20 66 72 6f 6d |d tolera|nce from|
|000007b0| 20 30 2e 35 20 74 6f 20 | 31 20 4c 53 42 2c 20 61 | 0.5 to |1 LSB, a|
|000007c0| 6e 64 20 6e 6f 77 20 75 | 73 65 20 74 68 65 20 68 |nd now u|se the h|
|000007d0| 69 67 68 65 73 74 0d 09 | 09 09 6c 75 6d 69 6e 61 |ighest..|..lumina|
|000007e0| 6e 63 65 20 67 61 69 6e | 20 28 77 6f 72 73 74 20 |nce gain| (worst |
|000007f0| 63 61 73 65 29 20 6f 76 | 65 72 20 74 68 65 20 72 |case) ov|er the r|
|00000800| 65 71 75 65 73 74 65 64 | 20 72 61 6e 67 65 20 74 |equested| range t|
|00000810| 6f 20 74 72 61 6e 73 66 | 6f 72 6d 20 69 74 0d 09 |o transf|orm it..|
|00000820| 09 09 69 6e 74 6f 20 61 | 20 6c 75 6d 69 6e 61 6e |..into a| luminan|
|00000830| 63 65 20 64 69 66 66 65 | 72 65 6e 63 65 20 74 6f |ce diffe|rence to|
|00000840| 6c 65 72 61 6e 63 65 2e | 0d 38 2f 32 31 2f 38 39 |lerance.|.8/21/89|
|00000850| 09 64 67 70 09 4d 61 64 | 65 20 6d 69 6e 6f 72 20 |.dgp.Mad|e minor |
|00000860| 69 6d 70 72 6f 76 65 6d | 65 6e 74 73 20 69 6e 20 |improvem|ents in |
|00000870| 4c 54 6f 56 28 29 20 74 | 6f 20 64 65 61 6c 20 77 |LToV() t|o deal w|
|00000880| 69 74 68 20 66 61 69 6c | 75 72 65 20 74 6f 20 63 |ith fail|ure to c|
|00000890| 6f 6e 76 65 72 67 65 20 | 64 75 65 20 74 6f 20 0d |onverge |due to .|
|000008a0| 09 09 09 67 65 74 74 69 | 6e 67 20 73 74 75 63 6b |...getti|ng stuck|
|000008b0| 20 69 6e 20 61 20 6c 6f | 63 61 6c 20 6d 69 6e 69 | in a lo|cal mini|
|000008c0| 6d 75 6d 20 6f 66 20 74 | 68 65 20 71 75 61 72 74 |mum of t|he quart|
|000008d0| 69 63 2e 20 4d 79 20 73 | 6f 6c 75 74 69 6f 6e 20 |ic. My s|olution |
|000008e0| 69 73 20 74 6f 20 6e 6f | 77 0d 09 09 09 72 65 71 |is to no|w....req|
|000008f0| 75 69 72 65 20 74 68 61 | 74 20 4c 6d 69 6e 20 61 |uire tha|t Lmin a|
|00000900| 6e 64 20 4c 6d 61 78 20 | 62 65 20 66 69 6c 6c 65 |nd Lmax |be fille|
|00000910| 64 20 69 6e 20 62 79 20 | 74 68 65 20 75 73 65 72 |d in by |the user|
|00000920| 20 69 6e 20 74 68 65 20 | 63 61 6c 69 62 72 61 74 | in the |calibrat|
|00000930| 69 6f 6e 0d 09 09 09 73 | 74 72 75 63 74 75 72 65 |ion....s|tructure|
|00000940| 2e 20 49 6e 20 70 72 61 | 63 74 69 63 65 20 74 68 |. In pra|ctice th|
|00000950| 69 73 20 77 69 6c 6c 20 | 67 75 61 72 61 6e 74 65 |is will |guarante|
|00000960| 65 20 74 68 61 74 20 74 | 68 65 20 6d 69 6e 69 6d |e that t|he minim|
|00000970| 75 6d 20 6c 75 6d 69 6e | 61 6e 63 65 0d 09 09 09 |um lumin|ance....|
|00000980| 77 69 6c 6c 20 6e 6f 74 | 20 62 65 20 62 65 6c 6f |will not| be belo|
|00000990| 77 20 74 68 65 20 6c 6f | 63 61 6c 20 6d 69 6e 69 |w the lo|cal mini|
|000009a0| 6d 75 6d 20 66 6f 75 6e | 64 20 61 74 20 74 68 65 |mum foun|d at the|
|000009b0| 20 62 61 73 65 20 6f 66 | 20 74 68 65 20 72 69 73 | base of| the ris|
|000009c0| 69 6e 67 20 63 75 72 76 | 65 2e 0d 09 09 09 4c 61 |ing curv|e.....La|
|000009d0| 73 74 20 77 65 65 6b 20 | 49 20 61 6c 73 6f 20 63 |st week |I also c|
|000009e0| 68 61 6e 67 65 64 20 74 | 68 65 20 4c 54 6f 56 20 |hanged t|he LToV |
|000009f0| 61 6c 67 6f 72 69 74 68 | 6d 20 73 6c 69 67 68 74 |algorith|m slight|
|00000a00| 6c 79 2c 20 74 6f 20 64 | 6f 20 61 20 62 69 73 65 |ly, to d|o a bise|
|00000a10| 63 74 69 6f 6e 20 69 66 | 0d 09 09 09 4e 65 77 74 |ction if|....Newt|
|00000a20| 6f 6e 27 73 20 6d 65 74 | 68 6f 64 20 77 6f 75 6c |on's met|hod woul|
|00000a30| 64 20 74 61 6b 65 20 75 | 73 20 6f 75 74 20 6f 66 |d take u|s out of|
|00000a40| 20 72 61 6e 67 65 2e 0d | 39 2f 37 2f 38 39 20 64 | range..|9/7/89 d|
|00000a50| 67 70 09 46 69 78 65 64 | 20 62 75 67 20 69 6e 20 |gp.Fixed| bug in |
|00000a60| 73 6f 72 74 69 6e 67 20 | 72 6f 75 74 69 6e 65 2c |sorting |routine,|
|00000a70| 20 53 6f 72 74 28 29 2e | 0d 39 2f 31 30 2f 38 39 | Sort().|.9/10/89|
|00000a80| 20 64 67 70 09 43 6f 6d | 6d 65 6e 74 65 64 20 6f | dgp.Com|mented o|
|00000a90| 75 74 20 74 68 65 20 70 | 6f 6c 79 6e 6f 6d 69 61 |ut the p|olynomia|
|00000aa0| 6c 20 76 65 72 73 69 6f | 6e 73 20 6f 66 20 56 54 |l versio|ns of VT|
|00000ab0| 6f 4c 20 61 6e 64 20 4c | 54 6f 56 20 61 6e 64 20 |oL and L|ToV and |
|00000ac0| 72 65 70 6c 61 63 65 20 | 74 68 65 6d 20 62 79 0d |replace |them by.|
|00000ad0| 09 09 09 6e 65 77 20 76 | 65 72 73 69 6f 6e 73 20 |...new v|ersions |
|00000ae0| 74 68 61 74 20 75 73 65 | 20 61 20 70 6f 77 65 72 |that use| a power|
|00000af0| 20 6c 61 77 2e 20 54 68 | 65 20 70 6f 77 65 72 20 | law. Th|e power |
|00000b00| 6c 61 77 20 69 73 20 61 | 20 6d 61 72 67 69 6e 61 |law is a| margina|
|00000b10| 6c 6c 79 20 62 65 74 74 | 65 72 20 66 69 74 0d 09 |lly bett|er fit..|
|00000b20| 09 09 74 68 61 6e 20 61 | 20 36 74 68 20 6f 72 64 |..than a| 6th ord|
|00000b30| 65 72 20 70 6f 6c 79 6e | 6f 6d 69 61 6c 20 28 75 |er polyn|omial (u|
|00000b40| 73 69 6e 67 20 6f 6e 6c | 79 20 34 20 69 6e 73 74 |sing onl|y 4 inst|
|00000b50| 65 61 64 20 6f 66 20 37 | 20 70 61 72 61 6d 65 74 |ead of 7| paramet|
|00000b60| 65 72 73 29 20 61 6e 64 | 20 69 74 73 0d 09 09 09 |ers) and| its....|
|00000b70| 69 6e 76 65 72 73 65 20 | 63 61 6e 20 62 65 20 63 |inverse |can be c|
|00000b80| 6f 6d 70 75 74 65 64 20 | 6d 75 63 68 20 6d 6f 72 |omputed |much mor|
|00000b90| 65 20 71 75 69 63 6b 6c | 79 2c 20 61 62 6f 75 74 |e quickl|y, about|
|00000ba0| 20 30 2e 33 20 6d 73 20 | 69 6e 73 74 65 61 64 20 | 0.3 ms |instead |
|00000bb0| 6f 66 20 32 20 6d 73 2e | 0d 39 2f 31 31 2f 38 39 |of 2 ms.|.9/11/89|
|00000bc0| 20 64 67 70 09 44 65 63 | 69 64 69 6e 67 20 74 6f | dgp.Dec|iding to|
|00000bd0| 20 62 65 20 69 6e 64 65 | 63 69 73 69 76 65 2c 20 | be inde|cisive, |
|00000be0| 49 20 69 6e 74 72 6f 64 | 75 63 65 64 20 61 20 63 |I introd|uced a c|
|00000bf0| 6f 6e 64 69 74 69 6f 6e | 61 6c 20 50 4f 57 45 52 |ondition|al POWER|
|00000c00| 5f 4c 41 57 5f 46 49 54 | 0d 09 09 09 74 6f 20 63 |_LAW_FIT|....to c|
|00000c10| 6f 6e 74 72 6f 6c 20 74 | 68 65 20 63 68 6f 69 63 |ontrol t|he choic|
|00000c20| 65 20 6f 66 20 70 6f 77 | 65 72 20 6c 61 77 20 6f |e of pow|er law o|
|00000c30| 72 20 70 6f 6c 79 6e 6f | 6d 69 61 6c 20 66 69 74 |r polyno|mial fit|
|00000c40| 20 66 6f 72 20 4c 54 6f | 56 20 61 6e 64 20 56 54 | for LTo|V and VT|
|00000c50| 6f 4c 2e 0d 39 2f 31 36 | 2f 38 39 09 64 67 70 09 |oL..9/16|/89.dgp.|
|00000c60| 48 61 76 69 6e 67 20 66 | 69 6e 69 73 68 65 64 20 |Having f|inished |
|00000c70| 77 72 69 74 69 6e 67 20 | 74 68 65 20 70 61 70 65 |writing |the pape|
|00000c80| 72 20 28 50 65 6c 6c 69 | 20 26 20 5a 68 61 6e 67 |r (Pelli| & Zhang|
|00000c90| 2c 20 31 39 39 31 29 20 | 49 20 63 61 6d 65 20 62 |, 1991) |I came b|
|00000ca0| 61 63 6b 20 74 6f 0d 09 | 09 09 63 68 61 6e 67 65 |ack to..|..change|
|00000cb0| 20 74 68 65 20 70 72 6f | 67 72 61 6d 20 74 6f 20 | the pro|gram to |
|00000cc0| 61 67 72 65 65 20 77 69 | 74 68 20 77 68 61 74 20 |agree wi|th what |
|00000cd0| 49 20 77 72 6f 74 65 2e | 20 49 20 63 68 61 6e 67 |I wrote.| I chang|
|00000ce0| 65 64 20 74 68 65 20 65 | 71 75 69 76 61 6c 65 6e |ed the e|quivalen|
|00000cf0| 74 0d 09 09 09 6e 75 6d | 62 65 72 20 74 6f 6c 65 |t....num|ber tole|
|00000d00| 72 61 6e 63 65 20 74 6f | 20 62 65 20 74 68 65 20 |rance to| be the |
|00000d10| 73 75 6d 20 69 6e 73 74 | 65 61 64 20 6f 66 20 74 |sum inst|ead of t|
|00000d20| 68 65 20 6d 61 78 69 6d | 75 6d 20 6f 66 20 74 68 |he maxim|um of th|
|00000d30| 65 20 0d 09 09 09 76 61 | 72 69 61 62 6c 65 2d 64 |e ....va|riable-d|
|00000d40| 61 63 20 67 61 69 6e 73 | 2e 0d 39 2f 32 35 2f 38 |ac gains|..9/25/8|
|00000d50| 39 20 64 67 70 20 46 69 | 78 65 64 20 6d 69 6e 6f |9 dgp Fi|xed mino|
|00000d60| 72 20 62 75 67 20 69 6e | 20 63 6f 6d 70 75 74 61 |r bug in| computa|
|00000d70| 74 69 6f 6e 20 6f 66 20 | 74 6f 6c 65 72 61 6e 63 |tion of |toleranc|
|00000d80| 65 2e 20 4e 6f 77 20 67 | 69 76 65 73 20 63 6f 72 |e. Now g|ives cor|
|00000d90| 72 65 63 74 20 61 6e 73 | 77 65 72 20 65 76 65 6e |rect ans|wer even|
|00000da0| 0d 09 09 09 77 68 65 6e | 20 74 68 65 20 6c 6f 77 |....when| the low|
|00000db0| 4c 75 6d 69 6e 61 6e 63 | 65 20 6f 72 20 68 69 67 |Luminanc|e or hig|
|00000dc0| 68 4c 75 6d 69 6e 61 6e | 63 65 20 69 73 20 6f 75 |hLuminan|ce is ou|
|00000dd0| 74 20 6f 66 20 72 61 6e | 67 65 2e 0d 31 30 2f 39 |t of ran|ge..10/9|
|00000de0| 2f 38 39 20 64 67 70 09 | 4d 61 64 65 20 6d 69 6e |/89 dgp.|Made min|
|00000df0| 6f 72 20 63 68 61 6e 67 | 65 20 73 6f 20 74 68 61 |or chang|e so tha|
|00000e00| 74 20 77 68 65 6e 20 73 | 6f 6d 65 20 6f 66 20 74 |t when s|ome of t|
|00000e10| 68 65 20 67 61 69 6e 5b | 5d 20 61 72 65 20 7a 65 |he gain[|] are ze|
|00000e20| 72 6f 20 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 20 |ro SetLu|minance |
|00000e30| 77 69 6c 6c 0d 09 09 09 | 6c 6f 61 64 20 7a 65 72 |will....|load zer|
|00000e40| 6f 20 69 6e 74 6f 20 74 | 68 65 20 75 6e 75 73 65 |o into t|he unuse|
|00000e50| 64 20 63 6f 6c 6f 72 53 | 70 65 63 20 61 72 72 61 |d colorS|pec arra|
|00000e60| 79 20 65 6c 65 6d 65 6e | 74 73 2e 20 54 68 69 73 |y elemen|ts. This|
|00000e70| 20 69 73 20 6f 6e 6c 79 | 20 61 20 63 6f 73 6d 65 | is only| a cosme|
|00000e80| 74 69 63 0d 09 09 09 63 | 68 61 6e 67 65 2e 0d 31 |tic....c|hange..1|
|00000e90| 30 2f 32 38 2f 38 39 20 | 64 67 70 20 4d 61 64 65 |0/28/89 |dgp Made|
|00000ea0| 20 6d 69 6e 6f 72 20 63 | 68 61 6e 67 65 73 2e 20 | minor c|hanges. |
|00000eb0| 49 20 64 65 63 6c 61 72 | 65 64 20 4c 54 6f 56 50 |I declar|ed LToVP|
|00000ec0| 6f 6c 79 6e 6f 6d 69 61 | 6c 20 61 6e 64 20 4c 54 |olynomia|l and LT|
|00000ed0| 6f 56 50 6f 77 65 72 20 | 61 6e 64 0d 09 09 09 56 |oVPower |and....V|
|00000ee0| 54 6f 4c 50 6f 6c 79 6e | 6f 6d 69 61 6c 20 61 6e |ToLPolyn|omial an|
|00000ef0| 64 20 56 54 6f 4c 50 6f | 77 65 72 20 69 6e 73 74 |d VToLPo|wer inst|
|00000f00| 65 61 64 20 6f 66 20 68 | 61 76 69 6e 67 20 61 20 |ead of h|aving a |
|00000f10| 63 6f 6e 64 69 74 69 6f | 6e 61 6c 20 63 6f 6d 70 |conditio|nal comp|
|00000f20| 69 6c 61 74 69 6f 6e 2e | 20 0d 09 09 09 54 68 69 |ilation.| ....Thi|
|00000f30| 73 20 6d 61 6b 65 73 20 | 62 6f 74 68 20 66 6c 61 |s makes |both fla|
|00000f40| 76 6f 72 73 20 6f 66 20 | 72 6f 75 74 69 6e 65 20 |vors of |routine |
|00000f50| 61 6c 77 61 79 73 20 61 | 76 61 69 6c 61 62 6c 65 |always a|vailable|
|00000f60| 2e 20 49 20 61 6c 73 6f | 20 63 68 61 6e 67 65 64 |. I also| changed|
|00000f70| 20 0d 09 09 09 4c 54 6f | 56 50 6f 6c 79 6e 6f 6d | ....LTo|VPolynom|
|00000f80| 69 61 6c 20 74 6f 20 75 | 73 65 20 4c 54 6f 56 50 |ial to u|se LToVP|
|00000f90| 6f 77 65 72 20 69 6e 73 | 74 65 61 64 20 6f 66 20 |ower ins|tead of |
|00000fa0| 4c 54 6f 56 51 75 61 64 | 72 61 74 69 63 20 66 6f |LToVQuad|ratic fo|
|00000fb0| 72 20 69 74 73 20 69 6e | 69 74 69 61 6c 20 0d 09 |r its in|itial ..|
|00000fc0| 09 09 67 75 65 73 73 2e | 20 54 68 65 20 71 75 61 |..guess.| The qua|
|00000fd0| 64 72 61 74 69 63 20 67 | 75 65 73 73 20 77 61 73 |dratic g|uess was|
|00000fe0| 20 6f 66 74 65 6e 20 70 | 6f 6f 72 20 61 6e 64 20 | often p|oor and |
|00000ff0| 6f 63 63 61 73 69 6f 6e | 61 6c 6c 79 20 6c 65 64 |occasion|ally led|
|00001000| 20 74 6f 20 0d 09 09 09 | 63 6f 6e 76 65 72 67 65 | to ....|converge|
|00001010| 6e 63 65 20 70 72 6f 62 | 6c 65 6d 73 2e 20 49 66 |nce prob|lems. If|
|00001020| 20 74 68 65 20 70 6f 77 | 65 72 20 6c 61 77 20 66 | the pow|er law f|
|00001030| 69 74 20 69 73 20 6e 6f | 74 20 61 76 61 69 6c 61 |it is no|t availa|
|00001040| 62 6c 65 20 74 68 65 6e | 20 69 74 20 72 65 76 65 |ble then| it reve|
|00001050| 72 74 73 0d 09 09 09 74 | 6f 20 75 73 69 6e 67 20 |rts....t|o using |
|00001060| 74 68 65 20 71 75 61 64 | 72 61 74 69 63 20 66 69 |the quad|ratic fi|
|00001070| 74 2e 20 49 66 20 74 68 | 61 74 27 73 20 6e 6f 74 |t. If th|at's not|
|00001080| 20 61 76 61 69 6c 61 62 | 6c 65 20 74 68 65 6e 20 | availab|le then |
|00001090| 69 74 20 72 65 76 65 72 | 74 73 20 74 6f 20 75 73 |it rever|ts to us|
|000010a0| 69 6e 67 0d 09 09 09 61 | 20 6d 69 64 64 6c 65 2d |ing....a| middle-|
|000010b0| 6f 66 2d 72 61 6e 67 65 | 20 67 75 65 73 73 2e 0d |of-range| guess..|
|000010c0| 31 30 2f 32 38 2f 38 39 | 20 64 67 70 20 49 20 65 |10/28/89| dgp I e|
|000010d0| 6c 69 6d 69 6e 61 74 65 | 64 20 74 68 65 20 63 6f |liminate|d the co|
|000010e0| 6d 70 69 6c 65 2d 74 69 | 6d 65 20 66 6c 61 67 20 |mpile-ti|me flag |
|000010f0| 50 4f 57 45 52 5f 4c 41 | 57 5f 46 49 54 20 61 6e |POWER_LA|W_FIT an|
|00001100| 64 20 69 6e 73 74 65 61 | 64 20 75 73 65 20 77 68 |d instea|d use wh|
|00001110| 69 63 68 65 76 65 72 2c | 20 0d 09 09 09 70 6f 6c |ichever,| ....pol|
|00001120| 79 6e 6f 6d 69 61 6c 20 | 6f 72 20 70 6f 77 65 72 |ynomial |or power|
|00001130| 2c 20 70 72 6f 76 69 64 | 65 73 20 61 20 62 65 74 |, provid|es a bet|
|00001140| 74 65 72 20 66 69 74 2c | 20 61 73 20 64 65 74 65 |ter fit,| as dete|
|00001150| 72 6d 69 6e 65 64 20 61 | 74 20 72 75 6e 20 74 69 |rmined a|t run ti|
|00001160| 6d 65 2e 20 49 20 0d 09 | 09 09 62 69 61 73 65 64 |me. I ..|..biased|
|00001170| 20 74 68 65 20 63 6f 6d | 70 61 72 69 73 6f 6e 20 | the com|parison |
|00001180| 6f 66 20 72 6d 73 20 65 | 72 72 6f 72 20 74 6f 20 |of rms e|rror to |
|00001190| 66 61 76 6f 72 20 74 68 | 65 20 70 6f 77 65 72 20 |favor th|e power |
|000011a0| 6c 61 77 20 66 69 74 20 | 73 69 6e 63 65 20 69 74 |law fit |since it|
|000011b0| 20 68 61 73 20 0d 09 09 | 09 66 65 77 20 70 61 72 | has ...|.few par|
|000011c0| 61 6d 65 74 65 72 73 20 | 61 6e 64 20 63 61 6e 20 |ameters |and can |
|000011d0| 62 65 20 69 6e 76 65 72 | 74 65 64 20 6d 75 63 68 |be inver|ted much|
|000011e0| 20 6d 6f 72 65 20 71 75 | 69 63 6b 6c 79 2e 20 4e | more qu|ickly. N|
|000011f0| 6f 74 65 3a 20 69 66 20 | 74 68 65 20 0d 09 09 09 |ote: if |the ....|
|00001200| 70 6f 77 65 72 2c 20 70 | 6f 6c 79 6e 6f 6d 69 61 |power, p|olynomia|
|00001210| 6c 2c 20 6f 72 20 71 75 | 61 64 72 61 74 69 63 20 |l, or qu|adratic |
|00001220| 66 69 74 20 70 61 72 61 | 6d 65 74 65 72 73 20 61 |fit para|meters a|
|00001230| 72 65 20 6e 6f 74 20 73 | 75 70 70 6c 69 65 64 20 |re not s|upplied |
|00001240| 74 68 65 6e 20 74 68 65 | 20 0d 09 09 09 61 70 70 |then the| ....app|
|00001250| 72 6f 70 72 69 61 74 65 | 20 4c 52 2e 70 6f 77 65 |ropriate| LR.powe|
|00001260| 72 45 72 72 6f 72 2c 20 | 4c 52 2e 70 6f 6c 79 6e |rError, |LR.polyn|
|00001270| 6f 6d 69 61 6c 45 72 72 | 6f 72 2c 20 6f 72 20 4c |omialErr|or, or L|
|00001280| 52 2e 71 75 61 64 72 61 | 74 69 63 45 72 72 6f 72 |R.quadra|ticError|
|00001290| 20 66 69 65 6c 64 20 0d | 09 09 09 73 68 6f 75 6c | field .|...shoul|
|000012a0| 64 20 62 65 20 73 65 74 | 20 74 6f 20 69 6e 66 69 |d be set| to infi|
|000012b0| 6e 69 74 79 3a 20 49 4e | 46 20 6f 72 20 31 2e 30 |nity: IN|F or 1.0|
|000012c0| 2f 30 2e 30 2e 0d 31 32 | 2f 35 2f 38 39 09 64 67 |/0.0..12|/5/89.dg|
|000012d0| 70 09 41 64 64 65 64 20 | 74 68 65 20 74 72 69 76 |p.Added |the triv|
|000012e0| 69 61 6c 20 72 6f 75 74 | 69 6e 65 20 4c 54 6f 4c |ial rout|ine LToL|
|000012f0| 28 29 20 77 68 69 63 68 | 20 65 6e 66 6f 72 63 65 |() which| enforce|
|00001300| 73 20 74 68 65 20 62 6f | 75 6e 64 73 20 4c 50 2d |s the bo|unds LP-|
|00001310| 3e 4c 4d 69 6e 20 61 6e | 64 20 0d 09 09 09 4c 50 |>LMin an|d ....LP|
|00001320| 2d 3e 4c 4d 61 78 2e 0d | 34 2f 32 2f 39 30 09 64 |->LMax..|4/2/90.d|
|00001330| 67 70 09 43 61 70 69 74 | 61 6c 69 7a 65 64 20 74 |gp.Capit|alized t|
|00001340| 68 65 20 77 6f 72 64 20 | 22 54 6f 22 20 69 6e 20 |he word |"To" in |
|00001350| 61 6c 6c 20 66 75 6e 63 | 74 69 6f 6e 20 6e 61 6d |all func|tion nam|
|00001360| 65 73 2c 20 65 2e 67 2e | 20 4c 54 6f 4c 28 29 2e |es, e.g.| LToL().|
|00001370| 0d 34 2f 32 32 2f 39 30 | 09 64 67 70 09 56 65 72 |.4/22/90|.dgp.Ver|
|00001380| 73 69 6f 6e 20 31 2e 34 | 2e 20 4d 61 64 65 20 6d |sion 1.4|. Made m|
|00001390| 69 6e 6f 72 20 63 68 61 | 6e 67 65 73 20 74 6f 20 |inor cha|nges to |
|000013a0| 74 68 65 20 64 6f 63 75 | 6d 65 6e 74 61 74 69 6f |the docu|mentatio|
|000013b0| 6e 2e 20 52 65 6e 61 6d | 65 64 20 4c 54 6f 56 28 |n. Renam|ed LToV(|
|000013c0| 29 20 74 6f 0d 09 09 09 | 4c 54 6f 56 46 6f 72 6d |) to....|LToVForm|
|000013d0| 75 6c 61 69 63 28 29 2c | 20 61 6e 64 20 69 6e 74 |ulaic(),| and int|
|000013e0| 72 6f 64 75 63 65 64 20 | 61 20 6e 65 77 20 4c 54 |roduced |a new LT|
|000013f0| 6f 56 28 29 20 74 68 61 | 74 20 75 73 65 73 20 61 |oV() tha|t uses a|
|00001400| 20 74 61 62 6c 65 20 74 | 6f 20 72 75 6e 20 66 61 | table t|o run fa|
|00001410| 73 74 65 72 2e 0d 09 09 | 09 4c 54 6f 56 28 29 20 |ster....|.LToV() |
|00001420| 74 61 6b 65 73 20 61 6e | 20 61 76 65 72 61 67 65 |takes an| average|
|00001430| 20 6f 66 20 31 37 30 20 | b5 73 2c 20 77 68 65 72 | of 170 |.s, wher|
|00001440| 65 61 73 20 4c 54 6f 56 | 46 6f 72 6d 75 6c 61 69 |eas LToV|Formulai|
|00001450| 63 28 29 20 74 61 6b 65 | 73 0d 09 09 09 31 37 30 |c() take|s....170|
|00001460| 30 20 b5 73 2e 20 49 20 | 61 6c 73 6f 20 6e 6f 77 |0 .s. I |also now|
|00001470| 20 75 73 65 20 74 68 65 | 20 6c 75 6d 69 6e 61 6e | use the| luminan|
|00001480| 63 65 54 61 62 6c 65 2c | 20 69 66 20 61 76 61 69 |ceTable,| if avai|
|00001490| 6c 61 62 6c 65 2c 20 74 | 6f 20 73 70 65 65 64 20 |lable, t|o speed |
|000014a0| 75 70 0d 09 09 09 56 54 | 6f 4c 28 29 20 73 6c 69 |up....VT|oL() sli|
|000014b0| 67 68 74 6c 79 2c 20 66 | 72 6f 6d 20 33 31 30 20 |ghtly, f|rom 310 |
|000014c0| b5 73 20 74 6f 20 31 38 | 30 20 b5 73 2e 20 45 61 |.s to 18|0 .s. Ea|
|000014d0| 63 68 20 63 61 6c 6c 20 | 74 6f 20 53 65 74 4c 75 |ch call |to SetLu|
|000014e0| 6d 69 6e 61 6e 63 65 28 | 29 20 6e 6f 77 0d 09 09 |minance(|) now...|
|000014f0| 09 74 61 6b 65 73 20 30 | 2e 39 20 6d 73 20 77 68 |.takes 0|.9 ms wh|
|00001500| 65 72 65 61 73 20 69 74 | 20 75 73 65 64 20 74 6f |ereas it| used to|
|00001510| 20 74 61 6b 65 20 32 2e | 35 20 6d 73 2e 20 54 68 | take 2.|5 ms. Th|
|00001520| 65 20 6c 6f 73 73 20 69 | 6e 20 61 63 63 75 72 61 |e loss i|n accura|
|00001530| 63 79 20 69 73 0d 09 09 | 09 6e 65 67 6c 69 67 69 |cy is...|.negligi|
|00001540| 62 6c 65 2e 20 54 68 65 | 20 69 6e 74 65 72 70 6f |ble. The| interpo|
|00001550| 6c 61 74 69 6f 6e 20 65 | 72 72 6f 72 20 63 61 6e |lation e|rror can|
|00001560| 20 62 65 20 72 65 64 75 | 63 65 64 20 73 74 69 6c | be redu|ced stil|
|00001570| 6c 20 66 75 72 74 68 65 | 72 20 62 79 0d 09 09 09 |l furthe|r by....|
|00001580| 69 6e 63 72 65 61 73 69 | 6e 67 20 4c 55 4d 49 4e |increasi|ng LUMIN|
|00001590| 41 4e 43 45 53 5f 49 4e | 5f 54 41 42 4c 45 2e 20 |ANCES_IN|_TABLE. |
|000015a0| 45 61 63 68 20 64 6f 75 | 62 6c 69 6e 67 20 6f 66 |Each dou|bling of|
|000015b0| 20 74 68 65 20 74 61 62 | 6c 65 20 73 69 7a 65 20 | the tab|le size |
|000015c0| 71 75 61 72 74 65 72 73 | 20 74 68 65 0d 09 09 09 |quarters| the....|
|000015d0| 6d 61 78 69 6d 75 6d 20 | 70 6f 73 73 69 62 6c 65 |maximum |possible|
|000015e0| 20 65 72 72 6f 72 20 6f | 66 20 74 68 65 20 69 6e | error o|f the in|
|000015f0| 74 65 72 70 6f 6c 61 74 | 69 6f 6e 2e 0d 34 2f 32 |terpolat|ion..4/2|
|00001600| 33 2f 39 30 09 64 67 70 | 09 41 64 64 65 64 20 61 |3/90.dgp|.Added a|
|00001610| 20 66 65 77 20 6c 69 6e | 65 73 20 6f 66 20 63 6f | few lin|es of co|
|00001620| 64 65 20 74 6f 20 4c 54 | 6f 56 28 29 20 74 6f 20 |de to LT|oV() to |
|00001630| 63 68 65 63 6b 20 6e 65 | 61 72 20 74 68 65 20 6c |check ne|ar the l|
|00001640| 61 73 74 20 69 6e 64 65 | 78 2c 20 69 6e 20 74 68 |ast inde|x, in th|
|00001650| 65 0d 09 09 09 73 70 69 | 72 69 74 20 6f 66 20 4e |e....spi|rit of N|
|00001660| 75 6d 65 72 69 63 61 6c | 20 52 65 63 69 70 65 73 |umerical| Recipes|
|00001670| 20 69 6e 20 43 2c 20 68 | 75 6e 74 2e 63 2c 20 62 | in C, h|unt.c, b|
|00001680| 65 66 6f 72 65 20 73 74 | 61 72 74 69 6e 67 20 74 |efore st|arting t|
|00001690| 68 65 20 62 69 73 65 63 | 74 69 6f 6e 0d 09 09 09 |he bisec|tion....|
|000016a0| 73 65 61 72 63 68 2e 20 | 49 20 75 70 64 61 74 65 |search. |I update|
|000016b0| 64 20 74 68 65 20 74 69 | 6d 65 73 20 69 6e 20 74 |d the ti|mes in t|
|000016c0| 68 65 20 34 2f 32 32 2f | 39 30 20 6e 6f 74 65 20 |he 4/22/|90 note |
|000016d0| 74 6f 20 72 65 66 6c 65 | 63 74 20 74 68 65 20 6c |to refle|ct the l|
|000016e0| 61 74 65 73 74 20 74 69 | 6d 69 6e 67 0d 09 09 09 |atest ti|ming....|
|000016f0| 62 79 20 54 65 73 74 4c | 75 6d 69 6e 61 6e 63 65 |by TestL|uminance|
|00001700| 2e 0d 37 2f 32 37 2f 39 | 30 09 64 67 70 09 54 69 |..7/27/9|0.dgp.Ti|
|00001710| 67 68 74 65 6e 65 64 20 | 75 70 20 74 68 65 20 65 |ghtened |up the e|
|00001720| 72 72 6f 72 20 63 68 65 | 63 6b 69 6e 67 20 66 6f |rror che|cking fo|
|00001730| 72 20 69 6c 6c 65 67 61 | 6c 20 65 6e 74 72 69 65 |r illega|l entrie|
|00001740| 73 20 69 6e 74 6f 20 74 | 68 65 20 63 6c 75 74 2e |s into t|he clut.|
|00001750| 20 49 20 68 61 76 65 0d | 09 09 09 74 68 65 20 69 | I have.|...the i|
|00001760| 6d 70 72 65 73 73 69 6f | 6e 20 74 68 61 74 2c 20 |mpressio|n that, |
|00001770| 63 6f 6e 74 72 61 72 79 | 20 74 6f 20 73 70 65 63 |contrary| to spec|
|00001780| 69 66 69 63 61 74 69 6f | 6e 2c 20 74 68 65 20 41 |ificatio|n, the A|
|00001790| 70 70 6c 65 20 76 69 64 | 65 6f 20 64 72 69 76 65 |pple vid|eo drive|
|000017a0| 72 0d 09 09 09 63 72 61 | 73 68 65 73 20 61 6e 64 |r....cra|shes and|
|000017b0| 20 63 6f 72 72 75 70 74 | 73 20 69 74 73 65 6c 66 | corrupt|s itself|
|000017c0| 20 69 66 20 67 69 76 65 | 6e 20 61 6e 20 6f 75 74 | if give|n an out|
|000017d0| 2d 6f 66 2d 72 61 6e 67 | 65 20 65 6e 74 72 79 20 |-of-rang|e entry |
|000017e0| 76 61 6c 75 65 20 69 6e | 20 61 0d 09 09 09 73 65 |value in| a....se|
|000017f0| 74 45 6e 74 72 79 20 43 | 6f 6e 74 72 6f 6c 20 63 |tEntry C|ontrol c|
|00001800| 61 6c 6c 2e 0d 39 2f 31 | 38 2f 39 30 09 64 67 70 |all..9/1|8/90.dgp|
|00001810| 09 43 68 61 6e 67 65 64 | 20 61 6c 6c 20 69 6e 73 |.Changed| all ins|
|00001820| 74 61 6e 63 65 73 20 6f | 66 20 22 76 22 20 74 6f |tances o|f "v" to|
|00001830| 20 22 56 22 2e 20 54 68 | 65 20 66 69 6e 61 6c 20 | "V". Th|e final |
|00001840| 76 65 72 73 69 6f 6e 20 | 6f 66 20 74 68 65 20 50 |version |of the P|
|00001850| 65 6c 6c 69 0d 09 09 09 | 26 20 5a 68 61 6e 67 20 |elli....|& Zhang |
|00001860| 28 31 39 39 31 29 20 70 | 61 70 65 72 20 72 65 66 |(1991) p|aper ref|
|00001870| 65 72 73 20 74 6f 20 74 | 68 65 20 6e 6f 6d 69 6e |ers to t|he nomin|
|00001880| 61 6c 20 76 6f 6c 74 61 | 67 65 20 76 3b 20 74 68 |al volta|ge v; th|
|00001890| 69 73 20 66 69 6c 65 0d | 09 09 09 6e 6f 77 20 72 |is file.|...now r|
|000018a0| 65 66 65 72 73 20 74 6f | 20 74 68 65 20 22 65 71 |efers to| the "eq|
|000018b0| 75 69 76 61 6c 65 6e 74 | 20 6e 75 6d 62 65 72 22 |uivalent| number"|
|000018c0| 20 56 3b 20 74 68 65 79 | 20 61 72 65 20 72 65 6c | V; they| are rel|
|000018d0| 61 74 65 64 20 62 79 20 | 56 3d 32 35 35 2a 76 2e |ated by |V=255*v.|
|000018e0| 0d 39 2f 32 34 2f 39 30 | 09 64 67 70 09 55 70 64 |.9/24/90|.dgp.Upd|
|000018f0| 61 74 65 64 20 74 68 65 | 20 64 6f 63 75 6d 65 6e |ated the| documen|
|00001900| 74 61 74 69 6f 6e 20 74 | 6f 20 63 6f 72 72 65 73 |tation t|o corres|
|00001910| 70 6f 6e 64 20 6d 6f 72 | 65 20 63 6c 6f 73 65 6c |pond mor|e closel|
|00001920| 79 20 74 6f 20 74 68 65 | 20 28 68 6f 70 65 66 75 |y to the| (hopefu|
|00001930| 6c 6c 79 29 0d 09 09 09 | 66 69 6e 61 6c 20 76 65 |lly)....|final ve|
|00001940| 72 73 69 6f 6e 20 6f 66 | 20 74 68 65 20 50 65 6c |rsion of| the Pel|
|00001950| 6c 69 20 26 20 5a 68 61 | 6e 67 20 28 31 39 39 31 |li & Zha|ng (1991|
|00001960| 29 20 70 61 70 65 72 2e | 0d 31 30 2f 32 39 2f 39 |) paper.|.10/29/9|
|00001970| 30 20 64 67 70 20 44 6f | 75 62 6c 65 64 20 73 70 |0 dgp Do|ubled sp|
|00001980| 65 65 64 20 6f 66 20 53 | 65 74 4c 75 6d 69 6e 61 |eed of S|etLumina|
|00001990| 6e 63 65 28 29 2e 20 4e | 6f 77 20 53 65 74 4c 75 |nce(). N|ow SetLu|
|000019a0| 6d 69 6e 61 6e 63 65 28 | 29 20 74 61 6b 65 73 20 |minance(|) takes |
|000019b0| 31 33 33 20 6d 73 20 74 | 6f 0d 09 09 09 64 6f 20 |133 ms t|o....do |
|000019c0| 61 20 63 6f 6d 70 6c 65 | 74 65 20 63 6c 75 74 20 |a comple|te clut |
|000019d0| 66 6f 72 20 61 20 73 6d | 61 6c 6c 20 6e 65 77 20 |for a sm|all new |
|000019e0| 6c 75 6d 69 6e 61 6e 63 | 65 20 72 61 6e 67 65 2c |luminanc|e range,|
|000019f0| 20 61 6e 64 20 74 61 6b | 65 73 20 31 38 38 20 6d | and tak|es 188 m|
|00001a00| 73 20 66 6f 72 20 61 0d | 09 09 09 6c 61 72 67 65 |s for a.|...large|
|00001a10| 20 6e 65 77 20 72 61 6e | 67 65 2e 20 54 68 69 73 | new ran|ge. This|
|00001a20| 20 72 65 71 75 69 72 65 | 64 20 6d 69 6e 6f 72 20 | require|d minor |
|00001a30| 63 68 61 6e 67 65 73 20 | 74 6f 20 53 65 74 4c 75 |changes |to SetLu|
|00001a40| 6d 69 6e 61 6e 63 65 52 | 61 6e 67 65 28 29 20 26 |minanceR|ange() &|
|00001a50| 20 4c 54 6f 56 28 29 2e | 0d 09 09 09 43 68 61 6e | LToV().|....Chan|
|00001a60| 67 65 64 20 61 6c 6c 20 | 66 75 6e 63 74 69 6f 6e |ged all |function|
|00001a70| 20 68 65 61 64 65 72 73 | 20 74 6f 20 53 74 61 6e | headers| to Stan|
|00001a80| 64 61 72 64 20 43 20 70 | 72 6f 74 6f 74 79 70 65 |dard C p|rototype|
|00001a90| 20 73 74 79 6c 65 2e 0d | 31 30 2f 33 30 2f 39 30 | style..|10/30/90|
|00001aa0| 20 64 67 70 20 52 65 70 | 6c 61 63 65 64 20 70 68 | dgp Rep|laced ph|
|00001ab0| 72 61 73 65 20 22 63 6c | 75 74 20 76 61 6c 75 65 |rase "cl|ut value|
|00001ac0| 22 20 62 79 20 22 6e 6f | 6d 69 6e 61 6c 20 76 6f |" by "no|minal vo|
|00001ad0| 6c 74 61 67 65 22 2c 20 | 66 6f 72 20 63 6f 6e 73 |ltage", |for cons|
|00001ae0| 69 73 74 65 6e 63 79 20 | 77 69 74 68 0d 09 09 09 |istency |with....|
|00001af0| 50 65 6c 6c 69 20 26 20 | 5a 68 61 6e 67 20 28 31 |Pelli & |Zhang (1|
|00001b00| 39 39 31 29 2e 0d 09 09 | 09 49 6e 74 72 6f 64 75 |991)....|.Introdu|
|00001b10| 63 65 64 20 6e 65 77 20 | 66 69 78 65 64 20 66 72 |ced new |fixed fr|
|00001b20| 61 63 74 69 6f 6e 20 64 | 61 74 61 20 74 79 70 65 |action d|ata type|
|00001b30| 20 63 61 6c 6c 65 64 20 | 22 4d 69 6c 6c 69 22 2c | called |"Milli",|
|00001b40| 20 64 65 66 69 6e 65 64 | 20 69 6e 20 4d 69 6c 6c | defined| in Mill|
|00001b50| 69 2e 68 2e 0d 09 09 09 | 42 79 20 6a 75 64 69 63 |i.h.....|By judic|
|00001b60| 69 6f 75 73 20 72 65 70 | 6c 61 63 65 6d 65 6e 74 |ious rep|lacement|
|00001b70| 20 6f 66 20 64 6f 75 62 | 6c 65 20 62 79 20 4d 69 | of doub|le by Mi|
|00001b80| 6c 6c 69 2c 20 70 61 72 | 74 69 63 75 6c 61 72 6c |lli, par|ticularl|
|00001b90| 79 20 69 6e 20 74 68 65 | 20 6c 75 6d 69 6e 61 6e |y in the| luminan|
|00001ba0| 63 65 0d 09 09 09 74 61 | 62 6c 65 2c 20 49 20 68 |ce....ta|ble, I h|
|00001bb0| 61 76 65 20 69 6e 63 72 | 65 61 73 65 64 20 74 68 |ave incr|eased th|
|00001bc0| 65 20 73 70 65 65 64 20 | 6f 66 20 53 65 74 4c 75 |e speed |of SetLu|
|00001bd0| 6d 69 6e 61 6e 63 65 20 | 62 79 20 61 20 66 61 63 |minance |by a fac|
|00001be0| 74 6f 72 20 6f 66 20 74 | 68 72 65 65 2e 0d 09 09 |tor of t|hree....|
|00001bf0| 09 41 20 4d 61 63 20 49 | 49 20 6e 6f 77 20 74 61 |.A Mac I|I now ta|
|00001c00| 6b 65 73 20 6f 6e 6c 79 | 20 34 32 20 74 6f 20 35 |kes only| 42 to 5|
|00001c10| 30 20 6d 73 20 74 6f 20 | 62 75 69 6c 64 20 61 20 |0 ms to |build a |
|00001c20| 77 68 6f 6c 65 20 63 6c | 75 74 2e 20 54 68 69 73 |whole cl|ut. This|
|00001c30| 20 6e 65 77 20 66 65 61 | 74 75 72 65 0d 09 09 09 | new fea|ture....|
|00001c40| 69 73 20 65 6e 61 62 6c | 65 64 20 62 79 20 73 65 |is enabl|ed by se|
|00001c50| 74 74 69 6e 67 20 46 41 | 53 54 5f 4c 55 4d 49 4e |tting FA|ST_LUMIN|
|00001c60| 41 4e 43 45 20 74 6f 20 | 31 20 69 6e 20 4c 75 6d |ANCE to |1 in Lum|
|00001c70| 69 6e 61 6e 63 65 2e 68 | 2e 20 54 68 65 72 65 20 |inance.h|. There |
|00001c80| 69 73 20 61 20 73 6c 69 | 67 68 74 0d 09 09 09 69 |is a sli|ght....i|
|00001c90| 6e 63 72 65 61 73 65 20 | 69 6e 20 74 68 65 20 6c |ncrease |in the l|
|00001ca0| 75 6d 69 6e 61 6e 63 65 | 20 74 6f 6c 65 72 61 6e |uminance| toleran|
|00001cb0| 63 65 2e 0d 31 30 2f 33 | 31 2f 39 30 20 64 67 70 |ce..10/3|1/90 dgp|
|00001cc0| 20 4d 6f 72 65 20 66 69 | 6e 65 20 74 75 6e 69 6e | More fi|ne tunin|
|00001cd0| 67 2e 20 4e 6f 77 20 74 | 61 6b 65 73 20 33 31 20 |g. Now t|akes 31 |
|00001ce0| 74 6f 20 34 34 20 6d 73 | 20 74 6f 20 62 75 69 6c |to 44 ms| to buil|
|00001cf0| 64 20 61 20 77 68 6f 6c | 65 20 63 6c 75 74 2e 20 |d a whol|e clut. |
|00001d00| 49 6e 74 72 6f 64 75 63 | 65 64 0d 09 09 09 63 6f |Introduc|ed....co|
|00001d10| 6e 64 69 74 69 6f 6e 61 | 6c 20 46 41 53 54 5f 4c |nditiona|l FAST_L|
|00001d20| 55 4d 49 4e 41 4e 43 45 | 20 69 6e 20 4c 75 6d 69 |UMINANCE| in Lumi|
|00001d30| 6e 61 6e 63 65 2e 68 20 | 74 68 61 74 20 63 61 75 |nance.h |that cau|
|00001d40| 73 65 73 20 74 68 65 20 | 73 61 6d 65 20 63 6f 64 |ses the |same cod|
|00001d50| 65 20 74 6f 0d 09 09 09 | 62 65 20 63 6f 6d 70 69 |e to....|be compi|
|00001d60| 6c 65 64 20 77 69 74 68 | 20 65 69 74 68 65 72 20 |led with| either |
|00001d70| 4d 69 6c 6c 69 20 6f 72 | 20 64 6f 75 62 6c 65 20 |Milli or| double |
|00001d80| 76 61 72 69 61 62 6c 65 | 73 2e 20 54 68 65 20 5f |variable|s. The _|
|00001d90| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 28 29 0d 09 |SetLumin|ance()..|
|00001da0| 09 09 72 6f 75 74 69 6e | 65 20 69 73 20 6e 6f 77 |..routin|e is now|
|00001db0| 20 71 75 69 74 65 20 70 | 6f 6c 69 73 68 65 64 2c | quite p|olished,|
|00001dc0| 20 61 6e 64 20 72 75 6e | 73 20 66 61 73 74 2e 20 | and run|s fast. |
|00001dd0| 41 6c 6c 20 76 61 72 69 | 61 62 6c 65 73 20 61 6e |All vari|ables an|
|00001de0| 64 20 72 6f 75 74 69 6e | 65 73 0d 09 09 09 77 68 |d routin|es....wh|
|00001df0| 6f 73 65 20 6e 61 6d 65 | 73 20 62 65 67 69 6e 20 |ose name|s begin |
|00001e00| 77 69 74 68 20 75 6e 64 | 65 72 73 63 6f 72 65 20 |with und|erscore |
|00001e10| 5f 20 61 72 65 20 77 72 | 69 74 74 65 6e 20 68 65 |_ are wr|itten he|
|00001e20| 72 65 20 77 69 74 68 20 | 74 79 70 65 20 4d 69 6c |re with |type Mil|
|00001e30| 6c 69 2c 20 62 75 74 0d | 09 09 09 69 66 20 46 41 |li, but.|...if FA|
|00001e40| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 20 69 73 20 |ST_LUMIN|ANCE is |
|00001e50| 66 61 6c 73 65 20 74 68 | 65 6e 20 74 68 69 73 20 |false th|en this |
|00001e60| 74 79 70 65 20 69 73 20 | 72 65 64 65 66 69 6e 65 |type is |redefine|
|00001e70| 64 20 28 69 6e 20 74 68 | 69 73 20 66 69 6c 65 20 |d (in th|is file |
|00001e80| 6f 6e 6c 79 29 0d 09 09 | 09 61 73 20 64 6f 75 62 |only)...|.as doub|
|00001e90| 6c 65 2c 20 61 6e 64 20 | 61 6c 6c 20 74 68 65 20 |le, and |all the |
|00001ea0| 4d 69 6c 6c 69 20 6d 61 | 63 72 6f 73 20 61 72 65 |Milli ma|cros are|
|00001eb0| 20 72 65 64 65 66 69 6e | 65 64 20 74 6f 20 62 65 | redefin|ed to be|
|00001ec0| 20 61 70 70 72 6f 70 72 | 69 61 74 65 20 66 6f 72 | appropr|iate for|
|00001ed0| 0d 09 09 09 61 20 64 6f | 75 62 6c 65 2e 20 53 6f |....a do|uble. So|
|00001ee0| 20 62 65 61 72 20 69 6e | 20 6d 69 6e 64 20 74 68 | bear in| mind th|
|00001ef0| 61 74 20 74 68 69 6e 67 | 73 20 62 65 67 69 6e 6e |at thing|s beginn|
|00001f00| 69 6e 67 20 77 69 74 68 | 20 75 6e 64 65 72 73 63 |ing with| undersc|
|00001f10| 6f 72 65 20 61 72 65 20 | 6f 66 0d 09 09 09 75 6e |ore are |of....un|
|00001f20| 6b 6e 6f 77 6e 20 74 79 | 70 65 2e 20 54 68 65 20 |known ty|pe. The |
|00001f30| 76 69 72 74 75 65 20 6f | 66 20 62 65 69 6e 67 20 |virtue o|f being |
|00001f40| 61 62 6c 65 20 74 6f 20 | 72 75 6e 20 74 68 65 20 |able to |run the |
|00001f50| 73 61 6d 65 20 63 6f 64 | 65 20 77 69 74 68 20 4d |same cod|e with M|
|00001f60| 69 6c 6c 69 20 6f 72 0d | 09 09 09 64 6f 75 62 6c |illi or.|...doubl|
|00001f70| 65 20 63 6f 6d 70 75 74 | 61 74 69 6f 6e 73 20 69 |e comput|ations i|
|00001f80| 73 20 74 68 61 74 20 69 | 66 20 79 6f 75 20 73 75 |s that i|f you su|
|00001f90| 73 70 65 63 74 20 61 6e | 20 65 72 72 6f 72 20 69 |spect an| error i|
|00001fa0| 6e 20 74 68 65 20 28 68 | 6f 6d 65 6d 61 64 65 29 |n the (h|omemade)|
|00001fb0| 0d 09 09 09 4d 69 6c 6c | 69 20 61 72 69 74 68 6d |....Mill|i arithm|
|00001fc0| 65 74 69 63 2c 20 79 6f | 75 20 63 61 6e 20 74 72 |etic, yo|u can tr|
|00001fd0| 79 20 6f 75 74 20 64 6f | 75 62 6c 65 20 61 72 69 |y out do|uble ari|
|00001fe0| 74 68 6d 65 74 69 63 20 | 73 69 6d 70 6c 79 20 62 |thmetic |simply b|
|00001ff0| 79 20 73 65 74 74 69 6e | 67 0d 09 09 09 46 41 53 |y settin|g....FAS|
|00002000| 54 5f 4c 55 4d 49 4e 41 | 4e 43 45 20 74 6f 20 30 |T_LUMINA|NCE to 0|
|00002010| 20 61 6e 64 20 72 65 63 | 6f 6d 70 69 6c 69 6e 67 | and rec|ompiling|
|00002020| 2e 0d 09 09 09 49 6e 20 | 74 68 65 20 69 6e 74 65 |.....In |the inte|
|00002030| 72 65 73 74 20 6f 66 20 | 73 70 65 65 64 20 49 20 |rest of |speed I |
|00002040| 68 61 76 65 20 73 74 72 | 65 61 6d 6c 69 6e 65 64 |have str|eamlined|
|00002050| 20 74 68 65 20 74 6f 6c | 65 72 61 6e 63 65 0d 09 | the tol|erance..|
|00002060| 09 09 63 6f 6d 70 75 74 | 61 74 69 6f 6e 2e 20 54 |..comput|ation. T|
|00002070| 68 65 20 6e 65 77 20 74 | 6f 6c 65 72 61 6e 63 65 |he new t|olerance|
|00002080| 73 20 61 72 65 20 70 72 | 6f 62 61 62 6c 79 20 61 |s are pr|obably a|
|00002090| 73 20 67 6f 6f 64 20 61 | 73 20 74 68 65 20 6f 6c |s good a|s the ol|
|000020a0| 64 20 6f 6e 65 73 2e 0d | 31 31 2f 32 2f 39 30 20 |d ones..|11/2/90 |
|000020b0| 64 67 70 20 41 64 64 65 | 64 20 5f 53 65 74 4c 75 |dgp Adde|d _SetLu|
|000020c0| 6d 69 6e 61 6e 63 65 73 | 28 29 20 73 75 62 72 6f |minances|() subro|
|000020d0| 75 74 69 6e 65 20 74 68 | 61 74 20 73 75 62 73 74 |utine th|at subst|
|000020e0| 69 74 75 74 65 73 20 6c | 69 6e 65 61 72 20 69 6e |itutes l|inear in|
|000020f0| 74 65 72 70 6f 6c 61 74 | 69 6f 6e 0d 09 09 09 66 |terpolat|ion....f|
|00002100| 6f 72 20 6d 6f 73 74 20 | 6f 66 20 74 68 65 20 63 |or most |of the c|
|00002110| 61 6c 6c 73 20 74 6f 20 | 5f 4c 54 6f 56 28 29 2e |alls to |_LToV().|
|00002120| 20 54 68 69 73 20 68 61 | 73 20 67 72 65 61 74 6c | This ha|s greatl|
|00002130| 79 20 73 70 65 65 64 65 | 64 20 75 70 0d 09 09 09 |y speede|d up....|
|00002140| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 73 41 6e 64 |SetLumin|ancesAnd|
|00002150| 52 61 6e 67 65 28 29 2c | 20 77 69 74 68 20 6d 69 |Range(),| with mi|
|00002160| 6e 6f 72 20 6c 6f 73 73 | 20 6f 66 20 61 63 63 75 |nor loss| of accu|
|00002170| 72 61 63 79 2e 20 41 20 | 63 6f 6d 70 6c 65 74 65 |racy. A |complete|
|00002180| 20 63 6c 75 74 20 6e 6f | 77 0d 09 09 09 74 61 6b | clut no|w....tak|
|00002190| 65 73 20 39 20 74 6f 20 | 33 31 20 6d 73 2e 20 45 |es 9 to |31 ms. E|
|000021a0| 76 65 6e 20 61 20 4d 61 | 63 20 49 49 20 63 61 6e |ven a Ma|c II can|
|000021b0| 20 6e 6f 77 20 63 6f 6d | 70 75 74 65 20 6c 6f 77 | now com|pute low|
|000021c0| 2d 63 6f 6e 74 72 61 73 | 74 20 63 6c 75 74 73 0d |-contras|t cluts.|
|000021d0| 09 09 09 6f 6e 20 74 68 | 65 20 66 6c 79 2c 20 62 |...on th|e fly, b|
|000021e0| 65 74 77 65 65 6e 20 66 | 72 61 6d 65 73 2e 20 28 |etween f|rames. (|
|000021f0| 54 68 65 20 75 73 65 72 | 20 6d 61 79 20 77 69 73 |The user| may wis|
|00002200| 68 20 74 6f 20 6f 70 74 | 69 6d 69 7a 65 20 74 68 |h to opt|imize th|
|00002210| 65 20 73 70 65 65 64 2d | 0d 09 09 09 61 63 63 75 |e speed-|....accu|
|00002220| 72 61 63 79 20 74 72 61 | 64 65 2d 6f 66 66 20 63 |racy tra|de-off c|
|00002230| 6f 6e 74 72 6f 6c 6c 65 | 64 20 62 79 20 74 68 65 |ontrolle|d by the|
|00002240| 20 4c 49 4e 45 41 52 5f | 56 5f 44 4f 4d 41 49 4e | LINEAR_|V_DOMAIN|
|00002250| 20 70 61 72 61 6d 65 74 | 65 72 2c 20 77 68 69 63 | paramet|er, whic|
|00002260| 68 0d 09 09 09 64 65 74 | 65 72 6d 69 6e 65 73 20 |h....det|ermines |
|00002270| 74 68 65 20 6d 61 78 69 | 6d 75 6d 20 77 69 64 74 |the maxi|mum widt|
|00002280| 68 20 6f 66 20 74 68 65 | 20 69 6e 74 65 72 70 6f |h of the| interpo|
|00002290| 6c 61 74 69 6f 6e 20 69 | 6e 74 65 72 76 61 6c 2e |lation i|nterval.|
|000022a0| 29 0d 31 31 2f 36 2f 39 | 30 20 64 67 70 20 52 65 |).11/6/9|0 dgp Re|
|000022b0| 70 6c 61 63 65 64 20 4d | 69 6c 6c 69 20 62 79 20 |placed M|illi by |
|000022c0| 46 49 58 45 44 2c 20 77 | 68 69 63 68 20 63 61 6e |FIXED, w|hich can|
|000022d0| 20 62 65 20 63 6f 6d 70 | 69 6c 65 64 20 61 73 20 | be comp|iled as |
|000022e0| 65 69 74 68 65 72 20 64 | 6f 75 62 6c 65 20 6f 72 |either d|ouble or|
|000022f0| 20 46 69 78 65 64 2e 0d | 09 09 09 54 68 65 20 46 | Fixed..|...The F|
|00002300| 69 78 65 64 20 6d 61 74 | 68 20 69 73 20 73 75 66 |ixed mat|h is suf|
|00002310| 66 69 63 69 65 6e 74 6c | 79 20 70 72 65 63 69 73 |ficientl|y precis|
|00002320| 65 20 61 73 20 74 6f 20 | 67 69 76 65 20 74 68 65 |e as to |give the|
|00002330| 20 73 61 6d 65 20 44 41 | 43 20 76 61 6c 75 65 73 | same DA|C values|
|00002340| 20 61 73 0d 09 09 09 64 | 6f 75 62 6c 65 20 6d 61 | as....d|ouble ma|
|00002350| 74 68 2e 0d 09 09 09 4e | 6f 77 20 66 69 67 75 72 |th.....N|ow figur|
|00002360| 65 20 6f 75 74 20 6f 70 | 74 69 6d 61 6c 20 62 69 |e out op|timal bi|
|00002370| 74 20 73 68 69 66 74 20 | 4c 54 2d 3e 4c 2e 4c 53 |t shift |LT->L.LS|
|00002380| 68 69 66 74 20 74 6f 20 | 70 72 65 73 65 72 76 65 |hift to |preserve|
|00002390| 20 61 73 20 6d 75 63 68 | 20 72 65 73 6f 6c 75 74 | as much| resolut|
|000023a0| 69 6f 6e 0d 09 09 09 61 | 73 20 70 6f 73 73 69 62 |ion....a|s possib|
|000023b0| 6c 65 20 77 68 65 6e 20 | 69 6e 74 65 72 70 6f 6c |le when |interpol|
|000023c0| 61 74 69 6e 67 20 69 6e | 20 5f 4c 54 6f 56 28 29 |ating in| _LToV()|
|000023d0| 2e 20 0d 09 09 09 41 20 | 63 6f 6d 70 6c 65 74 65 |. ....A |complete|
|000023e0| 20 63 6c 75 74 20 6e 6f | 77 20 74 61 6b 65 73 20 | clut no|w takes |
|000023f0| 38 20 74 6f 20 33 30 20 | 6d 73 2e 20 46 6f 72 20 |8 to 30 |ms. For |
|00002400| 74 68 72 65 73 68 6f 6c | 64 20 73 74 69 6d 75 6c |threshol|d stimul|
|00002410| 69 20 74 68 65 20 61 76 | 65 72 61 67 65 0d 09 09 |i the av|erage...|
|00002420| 09 74 69 6d 65 20 77 69 | 6c 6c 20 75 73 75 61 6c |.time wi|ll usual|
|00002430| 6c 79 20 62 65 20 6c 65 | 73 73 20 74 68 61 6e 20 |ly be le|ss than |
|00002440| 31 35 20 6d 73 2e 0d 31 | 31 2f 38 2f 39 30 20 64 |15 ms..1|1/8/90 d|
|00002450| 67 70 09 45 6c 69 6d 69 | 6e 61 74 65 64 20 67 61 |gp.Elimi|nated ga|
|00002460| 6d 6d 61 20 73 6c 6f 70 | 65 20 74 61 62 6c 65 20 |mma slop|e table |
|00002470| 73 69 6e 63 65 20 74 68 | 65 20 73 70 65 65 64 2d |since th|e speed-|
|00002480| 75 70 20 69 74 20 6f 66 | 66 65 72 65 64 20 77 61 |up it of|fered wa|
|00002490| 73 20 74 6f 6f 20 73 6d | 61 6c 6c 0d 09 09 09 74 |s too sm|all....t|
|000024a0| 6f 20 6d 65 61 73 75 72 | 65 2e 20 54 69 64 69 65 |o measur|e. Tidie|
|000024b0| 64 20 75 70 20 74 68 65 | 20 63 6f 6d 70 75 74 61 |d up the| computa|
|000024c0| 74 69 6f 6e 20 6f 66 20 | 4c 53 68 69 66 74 2e 0d |tion of |LShift..|
|000024d0| 38 2f 32 34 2f 39 31 09 | 64 67 70 09 4d 61 64 65 |8/24/91.|dgp.Made|
|000024e0| 20 63 6f 6d 70 61 74 69 | 62 6c 65 20 77 69 74 68 | compati|ble with|
|000024f0| 20 54 48 49 4e 4b 20 43 | 20 35 2e 30 2e 0d 31 32 | THINK C| 5.0..12|
|00002500| 2f 31 37 2f 39 31 20 64 | 67 70 20 41 64 64 65 64 |/17/91 d|gp Added|
|00002510| 20 6e 65 77 20 72 6f 75 | 74 69 6e 65 73 3a 20 49 | new rou|tines: I|
|00002520| 6e 63 72 65 6d 65 6e 74 | 4c 75 6d 69 6e 61 6e 63 |ncrement|Luminanc|
|00002530| 65 28 29 20 61 6e 64 20 | 47 65 74 56 28 29 2e 0d |e() and |GetV()..|
|00002540| 09 09 09 54 68 65 20 66 | 6f 72 6d 65 72 20 69 73 |...The f|ormer is|
|00002550| 20 75 73 65 64 20 74 6f | 20 6f 62 74 61 69 6e 20 | used to| obtain |
|00002560| 74 68 65 20 6c 6f 77 65 | 73 74 20 70 6f 73 73 69 |the lowe|st possi|
|00002570| 62 6c 65 20 63 6f 6e 74 | 72 61 73 74 2e 20 4f 6e |ble cont|rast. On|
|00002580| 20 61 20 6c 6f 67 20 63 | 6f 6e 74 72 61 73 74 0d | a log c|ontrast.|
|00002590| 09 09 09 73 63 61 6c 65 | 2c 20 6d 69 6e 75 73 20 |...scale|, minus |
|000025a0| 69 6e 66 69 6e 69 74 79 | 20 28 7a 65 72 6f 20 63 |infinity| (zero c|
|000025b0| 6f 6e 74 72 61 73 74 29 | 20 69 73 20 61 20 70 6f |ontrast)| is a po|
|000025c0| 6f 72 20 61 70 70 72 6f | 78 69 6d 61 74 69 6f 6e |or appro|ximation|
|000025d0| 20 74 6f 20 65 76 65 6e | 0d 09 09 09 61 20 73 6d | to even|....a sm|
|000025e0| 61 6c 6c 20 6c 6f 67 20 | 63 6f 6e 74 72 61 73 74 |all log |contrast|
|000025f0| 2e 0d 33 2f 31 31 2f 39 | 32 09 64 67 70 09 4d 69 |..3/11/9|2.dgp.Mi|
|00002600| 6e 6f 72 20 65 64 69 74 | 69 6e 67 20 6f 66 20 63 |nor edit|ing of c|
|00002610| 6f 6d 6d 65 6e 74 73 2e | 0d 31 32 2f 32 2f 39 32 |omments.|.12/2/92|
|00002620| 20 64 67 70 20 46 69 78 | 65 64 20 6d 69 6e 6f 72 | dgp Fix|ed minor|
|00002630| 20 62 75 67 20 69 6e 20 | 53 65 74 4c 75 6d 69 6e | bug in |SetLumin|
|00002640| 61 6e 63 65 52 61 6e 67 | 65 28 29 20 72 65 70 6f |anceRang|e() repo|
|00002650| 72 74 65 64 20 62 79 20 | 57 65 69 20 58 69 65 20 |rted by |Wei Xie |
|00002660| 61 6e 64 20 4b 65 6e 20 | 41 6c 65 78 61 6e 64 65 |and Ken |Alexande|
|00002670| 72 0d 09 09 09 74 68 61 | 74 20 63 6f 75 6c 64 20 |r....tha|t could |
|00002680| 63 61 75 73 65 20 74 68 | 65 20 54 48 49 4e 4b 20 |cause th|e THINK |
|00002690| 43 20 44 65 62 75 67 67 | 65 72 20 74 6f 20 72 65 |C Debugg|er to re|
|000026a0| 70 6f 72 74 20 61 6e 20 | 65 72 72 6f 72 20 77 68 |port an |error wh|
|000026b0| 65 6e 20 61 6e 20 0d 09 | 09 09 75 6e 69 6e 69 74 |en an ..|..uninit|
|000026c0| 69 61 6c 69 7a 65 64 20 | 64 6f 75 62 6c 65 20 56 |ialized |double V|
|000026d0| 5b 5d 20 77 61 73 20 63 | 6f 6e 76 65 72 74 65 64 |[] was c|onverted|
|000026e0| 20 74 6f 20 61 6e 20 69 | 6e 74 2e 20 54 68 65 20 | to an i|nt. The |
|000026f0| 76 61 6c 75 65 20 77 61 | 73 20 6e 6f 74 20 75 73 |value wa|s not us|
|00002700| 65 64 20 0d 09 09 09 66 | 6f 72 20 61 6e 79 74 68 |ed ....f|or anyth|
|00002710| 69 6e 67 2c 20 73 6f 20 | 74 68 69 73 20 77 61 73 |ing, so |this was|
|00002720| 20 69 6e 6e 6f 63 75 6f | 75 73 2e 0d 31 32 2f 31 | innocuo|us..12/1|
|00002730| 37 2f 39 32 20 64 67 70 | 20 31 2e 39 34 20 42 65 |7/92 dgp| 1.94 Be|
|00002740| 67 61 6e 20 65 6e 68 61 | 6e 63 65 6d 65 6e 74 20 |gan enha|ncement |
|00002750| 74 6f 20 61 6c 6c 6f 77 | 20 61 6e 79 20 64 61 63 |to allow| any dac|
|00002760| 53 69 7a 65 2c 20 6e 6f | 74 20 6a 75 73 74 20 38 |Size, no|t just 8|
|00002770| 2d 62 69 74 20 64 61 63 | 73 2e 20 49 20 68 61 76 |-bit dac|s. I hav|
|00002780| 65 0d 09 09 09 63 6f 6e | 66 69 72 6d 65 64 20 74 |e....con|firmed t|
|00002790| 68 61 74 20 65 76 65 72 | 79 74 68 69 6e 67 20 73 |hat ever|ything s|
|000027a0| 74 69 6c 6c 20 77 6f 72 | 6b 73 20 66 69 6e 65 20 |till wor|ks fine |
|000027b0| 77 69 74 68 20 38 2d 62 | 69 74 20 64 61 63 73 2c |with 8-b|it dacs,|
|000027c0| 20 62 75 74 20 49 20 64 | 6f 6e 27 74 0d 09 09 09 | but I d|on't....|
|000027d0| 68 61 76 65 20 61 20 39 | 2d 62 69 74 20 64 61 63 |have a 9|-bit dac|
|000027e0| 20 76 69 64 65 6f 20 63 | 61 72 64 20 74 6f 20 74 | video c|ard to t|
|000027f0| 65 73 74 20 69 74 20 61 | 6e 79 20 66 75 72 74 68 |est it a|ny furth|
|00002800| 65 72 2e 20 a5 43 41 55 | 54 49 4f 4e 3a 20 74 68 |er. .CAU|TION: th|
|00002810| 69 73 20 70 72 6f 62 61 | 62 6c 79 0d 09 09 09 64 |is proba|bly....d|
|00002820| 6f 65 73 20 6e 6f 74 20 | 79 65 74 20 77 6f 72 6b |oes not |yet work|
|00002830| 20 63 6f 72 72 65 63 74 | 6c 79 20 66 6f 72 20 39 | correct|ly for 9|
|00002840| 2d 62 69 74 20 64 61 63 | 73 2e 20 45 2e 67 2e 20 |-bit dac|s. E.g. |
|00002850| 69 74 20 73 65 65 6d 73 | 20 6c 69 6b 65 6c 79 20 |it seems| likely |
|00002860| 74 68 61 74 20 74 68 65 | 20 0d 09 09 09 66 69 78 |that the| ....fix|
|00002870| 65 64 20 70 6f 69 6e 74 | 20 6d 61 74 68 20 77 69 |ed point| math wi|
|00002880| 6c 6c 20 62 72 65 61 6b | 20 69 66 20 56 4d 61 78 |ll break| if VMax|
|00002890| 20 69 73 20 69 6e 63 72 | 65 61 73 65 64 20 74 6f | is incr|eased to|
|000028a0| 20 35 31 31 3b 20 61 20 | 6c 6f 74 20 6f 66 20 63 | 511; a |lot of c|
|000028b0| 61 72 65 66 75 6c 20 0d | 09 09 09 65 72 72 6f 72 |areful .|...error|
|000028c0| 20 61 6e 61 6c 79 73 69 | 73 20 77 65 6e 74 20 69 | analysi|s went i|
|000028d0| 6e 74 6f 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c |nto the |original|
|000028e0| 20 63 6f 64 69 6e 67 2c | 20 61 74 20 77 68 69 63 | coding,| at whic|
|000028f0| 68 20 74 69 6d 65 20 49 | 20 74 68 6f 75 67 68 74 |h time I| thought|
|00002900| 20 74 68 61 74 20 0d 09 | 09 09 69 74 20 77 61 73 | that ..|..it was|
|00002910| 20 73 61 66 65 20 74 6f | 20 61 73 73 75 6d 65 20 | safe to| assume |
|00002920| 61 6e 20 38 2d 62 69 74 | 20 64 61 63 20 28 69 2e |an 8-bit| dac (i.|
|00002930| 65 2e 20 56 4d 61 78 3d | 3d 32 35 35 29 2e 20 a5 |e. VMax=|=255). .|
|00002940| 52 65 6d 6f 76 65 64 20 | 6f 62 73 6f 6c 65 74 65 |Removed |obsolete|
|00002950| 20 0d 09 09 09 73 75 70 | 70 6f 72 74 20 66 6f 72 | ....sup|port for|
|00002960| 20 54 48 49 4e 4b 20 43 | 20 34 2e 20 0d 31 32 2f | THINK C| 4. .12/|
|00002970| 32 31 2f 39 32 20 64 67 | 70 20 4e 6f 20 6c 6f 6e |21/92 dg|p No lon|
|00002980| 67 65 72 20 6c 6f 61 64 | 20 75 6e 75 73 65 64 20 |ger load| unused |
|00002990| 64 61 63 20 62 69 74 73 | 2e 0d 31 2f 34 2f 39 33 |dac bits|..1/4/93|
|000029a0| 09 64 67 70 09 4c 6f 61 | 64 4c 75 6d 69 6e 61 6e |.dgp.Loa|dLuminan|
|000029b0| 63 65 73 20 6e 6f 77 20 | 63 68 65 63 6b 73 20 74 |ces now |checks t|
|000029c0| 68 65 20 67 64 54 79 70 | 65 2e 0d 35 2f 31 30 2f |he gdTyp|e..5/10/|
|000029d0| 39 33 09 64 67 70 09 49 | 66 20 64 72 69 76 65 72 |93.dgp.I|f driver|
|000029e0| 20 69 73 20 69 6e 20 67 | 72 61 79 20 6d 6f 64 65 | is in g|ray mode|
|000029f0| 20 28 69 2e 65 2e 20 6e | 6f 74 20 63 6f 6c 6f 72 | (i.e. n|ot color|
|00002a00| 29 20 74 68 65 6e 20 4c | 6f 61 64 4c 75 6d 69 6e |) then L|oadLumin|
|00002a10| 61 6e 63 65 73 20 6d 61 | 70 73 20 72 67 62 20 74 |ances ma|ps rgb t|
|00002a20| 6f 20 0d 09 09 09 67 72 | 61 79 20 62 79 20 73 69 |o ....gr|ay by si|
|00002a30| 6d 70 6c 79 20 63 6f 70 | 79 69 6e 67 20 74 68 65 |mply cop|ying the|
|00002a40| 20 67 72 65 65 6e 20 63 | 6f 6d 70 6f 6e 65 6e 74 | green c|omponent|
|00002a50| 20 74 6f 20 74 68 65 20 | 72 65 64 20 61 6e 64 20 | to the |red and |
|00002a60| 62 6c 75 65 20 63 6f 6d | 70 6f 6e 65 6e 74 73 2e |blue com|ponents.|
|00002a70| 0d 35 2f 31 32 2f 39 33 | 09 64 67 70 20 72 65 6d |.5/12/93|.dgp rem|
|00002a80| 6f 76 65 64 20 64 65 62 | 75 67 67 69 6e 67 20 63 |oved deb|ugging c|
|00002a90| 6f 64 65 20 74 68 61 74 | 20 66 6f 72 63 65 64 20 |ode that| forced |
|00002aa0| 69 73 47 72 61 79 20 74 | 6f 20 61 6c 77 61 79 73 |isGray t|o always|
|00002ab0| 20 62 65 20 74 72 75 65 | 2e 0d 33 2f 32 34 2f 39 | be true|..3/24/9|
|00002ac0| 34 09 64 67 70 09 61 64 | 64 65 64 20 4c 54 6f 45 |4.dgp.ad|ded LToE|
|00002ad0| 2c 20 4c 54 6f 45 4f 72 | 64 65 72 65 64 2c 20 61 |, LToEOr|dered, a|
|00002ae0| 6e 64 20 45 54 6f 4c 2e | 0d 36 2f 32 39 2f 39 34 |nd EToL.|.6/29/94|
|00002af0| 20 64 67 70 20 72 65 6e | 61 6d 65 64 20 22 4c 74 | dgp ren|amed "Lt|
|00002b00| 6f 45 4f 72 64 65 72 65 | 64 22 20 74 6f 20 22 4c |oEOrdere|d" to "L|
|00002b10| 54 6f 45 4f 72 64 65 72 | 65 64 22 2c 20 66 69 78 |ToEOrder|ed", fix|
|00002b20| 69 6e 67 20 65 72 72 6f | 6e 65 6f 75 73 20 63 61 |ing erro|neous ca|
|00002b30| 70 69 74 61 6c 69 7a 61 | 74 69 6f 6e 2e 0d 39 2f |pitaliza|tion..9/|
|00002b40| 32 38 2f 39 34 09 64 67 | 70 09 49 66 20 6e 65 63 |28/94.dg|p.If nec|
|00002b50| 65 73 73 61 72 79 2c 20 | 49 6e 63 72 65 6d 65 6e |essary, |Incremen|
|00002b60| 74 4c 75 6d 69 6e 61 6e | 63 65 20 6e 6f 77 20 62 |tLuminan|ce now b|
|00002b70| 75 6d 70 73 20 75 70 20 | 74 68 65 20 75 70 70 65 |umps up |the uppe|
|00002b80| 72 20 6c 75 6d 69 6e 61 | 6e 63 65 20 62 6f 75 6e |r lumina|nce boun|
|00002b90| 64 20 74 6f 20 0d 09 09 | 09 69 6e 63 6c 75 64 65 |d to ...|.include|
|00002ba0| 20 74 68 65 20 69 6e 63 | 72 65 6d 65 6e 74 65 64 | the inc|remented|
|00002bb0| 20 6c 75 6d 69 6e 61 6e | 63 65 2e 0d 31 30 2f 32 | luminan|ce..10/2|
|00002bc0| 35 2f 39 34 20 64 67 70 | 20 4c 6f 61 64 4c 75 6d |5/94 dgp| LoadLum|
|00002bd0| 69 6e 61 6e 63 65 20 61 | 6e 64 20 47 65 74 56 20 |inance a|nd GetV |
|00002be0| 6e 6f 77 20 69 67 6e 6f | 72 65 20 61 20 64 65 76 |now igno|re a dev|
|00002bf0| 69 63 65 20 77 69 74 68 | 20 6e 6f 20 64 72 69 76 |ice with| no driv|
|00002c00| 65 72 2e 20 28 45 2e 67 | 2e 20 61 20 64 65 76 69 |er. (E.g|. a devi|
|00002c10| 63 65 0d 09 09 09 63 72 | 65 61 74 65 64 20 62 79 |ce....cr|eated by|
|00002c20| 20 4e 65 77 47 57 6f 72 | 6c 64 2e 29 0d 31 32 2f | NewGWor|ld.).12/|
|00002c30| 32 39 2f 39 34 20 64 67 | 70 20 46 69 78 65 64 20 |29/94 dg|p Fixed |
|00002c40| 7a 65 72 6f 2d 64 69 76 | 69 64 65 20 68 61 6c 74 |zero-div|ide halt|
|00002c50| 20 69 6e 20 63 6f 6d 70 | 75 74 69 6e 67 20 46 41 | in comp|uting FA|
|00002c60| 53 54 5f 4c 55 4d 49 4e | 41 4e 43 45 20 5f 4c 54 |ST_LUMIN|ANCE _LT|
|00002c70| 6f 56 20 72 65 74 75 72 | 6e 65 64 20 76 61 6c 75 |oV retur|ned valu|
|00002c80| 65 2c 0d 09 09 09 72 65 | 70 6f 72 74 65 64 20 62 |e,....re|ported b|
|00002c90| 79 20 4a 6f 73 68 20 53 | 6f 6c 6f 6d 6f 6e 2e 20 |y Josh S|olomon. |
|00002ca0| 49 6e 63 72 65 61 73 65 | 64 20 4a 4d 41 58 20 66 |Increase|d JMAX f|
|00002cb0| 72 6f 6d 20 32 30 20 74 | 6f 20 33 30 20 74 6f 20 |rom 20 t|o 30 to |
|00002cc0| 65 6c 69 6d 69 6e 61 74 | 65 20 73 70 75 72 69 6f |eliminat|e spurio|
|00002cd0| 75 73 0d 09 09 09 77 61 | 72 6e 69 6e 67 20 69 6e |us....wa|rning in|
|00002ce0| 20 4c 54 6f 56 50 6f 6c | 79 6e 6f 6d 69 61 6c 2e | LToVPol|ynomial.|
|00002cf0| 0d 2a 2f 0d 23 69 6e 63 | 6c 75 64 65 20 22 56 69 |.*/.#inc|lude "Vi|
|00002d00| 64 65 6f 54 6f 6f 6c 62 | 6f 78 2e 68 22 09 09 2f |deoToolb|ox.h"../|
|00002d10| 2a 20 70 72 6f 74 6f 74 | 79 70 65 20 66 6f 72 20 |* protot|ype for |
|00002d20| 47 44 53 65 74 45 6e 74 | 72 69 65 73 28 29 20 2a |GDSetEnt|ries() *|
|00002d30| 2f 0d 23 69 6e 63 6c 75 | 64 65 20 22 4c 75 6d 69 |/.#inclu|de "Lumi|
|00002d40| 6e 61 6e 63 65 2e 68 22 | 0d 23 69 6e 63 6c 75 64 |nance.h"|.#includ|
|00002d50| 65 20 3c 61 73 73 65 72 | 74 2e 68 3e 0d 23 69 6e |e <asser|t.h>.#in|
|00002d60| 63 6c 75 64 65 20 3c 6d | 61 74 68 2e 68 3e 0d 0d |clude <m|ath.h>..|
|00002d70| 73 74 61 74 69 63 20 76 | 6f 69 64 20 53 6f 72 74 |static v|oid Sort|
|00002d80| 28 69 6e 74 20 6e 2c 64 | 6f 75 62 6c 65 20 61 72 |(int n,d|ouble ar|
|00002d90| 72 5b 5d 2c 69 6e 74 20 | 6b 72 72 5b 5d 29 3b 09 |r[],int |krr[]);.|
|00002da0| 2f 2a 20 66 6f 72 20 69 | 6e 74 65 72 6e 61 6c 20 |/* for i|nternal |
|00002db0| 75 73 65 20 6f 6e 6c 79 | 20 2a 2f 0d 0d 23 75 6e |use only| */..#un|
|00002dc0| 64 65 66 20 4c 6f 6e 67 | 54 6f 46 69 78 0d 23 75 |def Long|ToFix.#u|
|00002dd0| 6e 64 65 66 20 46 69 78 | 54 6f 4c 6f 6e 67 0d 23 |ndef Fix|ToLong.#|
|00002de0| 75 6e 64 65 66 20 44 6f | 75 62 6c 65 54 6f 46 69 |undef Do|ubleToFi|
|00002df0| 78 0d 23 75 6e 64 65 66 | 20 46 69 78 54 6f 44 6f |x.#undef| FixToDo|
|00002e00| 75 62 6c 65 0d 23 69 66 | 20 46 41 53 54 5f 4c 55 |uble.#if| FAST_LU|
|00002e10| 4d 49 4e 41 4e 43 45 0d | 09 23 64 65 66 69 6e 65 |MINANCE.|.#define|
|00002e20| 20 46 49 58 45 44 20 46 | 69 78 65 64 0d 09 23 69 | FIXED F|ixed..#i|
|00002e30| 66 20 21 4d 41 43 49 4e | 54 4f 53 48 0d 09 09 74 |f !MACIN|TOSH...t|
|00002e40| 79 70 65 64 65 66 20 6c | 6f 6e 67 20 46 69 78 65 |ypedef l|ong Fixe|
|00002e50| 64 3b 0d 09 09 23 64 65 | 66 69 6e 65 20 46 69 78 |d;...#de|fine Fix|
|00002e60| 4d 75 6c 28 78 2c 79 29 | 20 44 6f 75 62 6c 65 54 |Mul(x,y)| DoubleT|
|00002e70| 6f 46 69 78 28 46 69 78 | 54 6f 44 6f 75 62 6c 65 |oFix(Fix|ToDouble|
|00002e80| 28 78 29 2a 46 69 78 54 | 6f 44 6f 75 62 6c 65 28 |(x)*FixT|oDouble(|
|00002e90| 79 29 29 0d 09 09 23 64 | 65 66 69 6e 65 20 46 69 |y))...#d|efine Fi|
|00002ea0| 78 44 69 76 28 78 2c 79 | 29 20 44 6f 75 62 6c 65 |xDiv(x,y|) Double|
|00002eb0| 54 6f 46 69 78 28 46 69 | 78 54 6f 44 6f 75 62 6c |ToFix(Fi|xToDoubl|
|00002ec0| 65 28 78 29 2f 46 69 78 | 54 6f 44 6f 75 62 6c 65 |e(x)/Fix|ToDouble|
|00002ed0| 28 79 29 29 0d 09 23 65 | 6e 64 69 66 0d 09 23 64 |(y))..#e|ndif..#d|
|00002ee0| 65 66 69 6e 65 20 4c 6f | 6e 67 54 6f 46 69 78 28 |efine Lo|ngToFix(|
|00002ef0| 78 29 20 28 28 6c 6f 6e | 67 29 28 78 29 3c 3c 31 |x) ((lon|g)(x)<<1|
|00002f00| 36 29 0d 09 23 64 65 66 | 69 6e 65 20 46 69 78 54 |6)..#def|ine FixT|
|00002f10| 6f 4c 6f 6e 67 28 78 29 | 20 28 28 78 29 3e 3e 31 |oLong(x)| ((x)>>1|
|00002f20| 36 29 0d 09 23 64 65 66 | 69 6e 65 20 44 6f 75 62 |6)..#def|ine Doub|
|00002f30| 6c 65 54 6f 46 69 78 28 | 78 29 20 28 28 46 69 78 |leToFix(|x) ((Fix|
|00002f40| 65 64 29 28 28 78 29 2a | 36 35 35 33 36 2e 2b 30 |ed)((x)*|65536.+0|
|00002f50| 2e 35 29 29 0d 09 23 64 | 65 66 69 6e 65 20 46 69 |.5))..#d|efine Fi|
|00002f60| 78 54 6f 44 6f 75 62 6c | 65 28 78 29 20 28 28 64 |xToDoubl|e(x) ((d|
|00002f70| 6f 75 62 6c 65 29 28 78 | 29 2a 28 31 2e 2f 36 35 |ouble)(x|)*(1./65|
|00002f80| 35 33 36 2e 29 29 0d 09 | 23 64 65 66 69 6e 65 20 |536.))..|#define |
|00002f90| 44 28 78 29 20 46 69 78 | 54 6f 44 6f 75 62 6c 65 |D(x) Fix|ToDouble|
|00002fa0| 28 78 29 09 09 09 09 09 | 09 09 2f 2a 20 68 61 6e |(x).....|../* han|
|00002fb0| 64 79 20 66 6f 72 20 64 | 65 62 75 67 67 69 6e 67 |dy for d|ebugging|
|00002fc0| 20 2a 2f 0d 23 65 6c 73 | 65 0d 09 23 64 65 66 69 | */.#els|e..#defi|
|00002fd0| 6e 65 20 46 49 58 45 44 | 20 64 6f 75 62 6c 65 0d |ne FIXED| double.|
|00002fe0| 09 23 64 65 66 69 6e 65 | 20 46 69 78 4d 75 6c 28 |.#define| FixMul(|
|00002ff0| 78 2c 79 29 20 28 28 64 | 6f 75 62 6c 65 29 28 78 |x,y) ((d|ouble)(x|
|00003000| 29 2a 28 79 29 29 0d 09 | 23 64 65 66 69 6e 65 20 |)*(y))..|#define |
|00003010| 46 69 78 44 69 76 28 78 | 2c 79 29 20 28 28 64 6f |FixDiv(x|,y) ((do|
|00003020| 75 62 6c 65 29 28 78 29 | 2f 28 79 29 29 0d 09 23 |uble)(x)|/(y))..#|
|00003030| 64 65 66 69 6e 65 20 4c | 6f 6e 67 54 6f 46 69 78 |define L|ongToFix|
|00003040| 28 78 29 20 28 28 64 6f | 75 62 6c 65 29 28 78 29 |(x) ((do|uble)(x)|
|00003050| 29 0d 09 23 64 65 66 69 | 6e 65 20 46 69 78 54 6f |)..#defi|ne FixTo|
|00003060| 4c 6f 6e 67 28 78 29 20 | 28 28 6c 6f 6e 67 29 28 |Long(x) |((long)(|
|00003070| 78 29 29 0d 09 23 64 65 | 66 69 6e 65 20 44 6f 75 |x))..#de|fine Dou|
|00003080| 62 6c 65 54 6f 46 69 78 | 28 78 29 20 28 28 64 6f |bleToFix|(x) ((do|
|00003090| 75 62 6c 65 29 28 78 29 | 29 0d 09 23 64 65 66 69 |uble)(x)|)..#defi|
|000030a0| 6e 65 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 78 |ne FixTo|Double(x|
|000030b0| 29 20 28 28 64 6f 75 62 | 6c 65 29 28 78 29 29 0d |) ((doub|le)(x)).|
|000030c0| 23 65 6e 64 69 66 0d 0d | 23 75 6e 64 65 66 20 4d |#endif..|#undef M|
|000030d0| 41 58 0d 23 75 6e 64 65 | 66 20 4d 49 4e 0d 23 64 |AX.#unde|f MIN.#d|
|000030e0| 65 66 69 6e 65 20 4d 41 | 58 28 61 2c 62 29 20 28 |efine MA|X(a,b) (|
|000030f0| 28 61 29 20 3e 20 28 62 | 29 20 3f 20 28 61 29 20 |(a) > (b|) ? (a) |
|00003100| 3a 20 28 62 29 29 0d 23 | 64 65 66 69 6e 65 20 4d |: (b)).#|define M|
|00003110| 49 4e 28 61 2c 62 29 20 | 28 28 61 29 20 3c 20 28 |IN(a,b) |((a) < (|
|00003120| 62 29 20 3f 20 28 61 29 | 20 3a 20 28 62 29 29 0d |b) ? (a)| : (b)).|
|00003130| 0d 64 6f 75 62 6c 65 20 | 45 54 6f 4c 28 4c 75 6d |.double |EToL(Lum|
|00003140| 69 6e 61 6e 63 65 52 65 | 63 6f 72 64 20 2a 4c 50 |inanceRe|cord *LP|
|00003150| 2c 69 6e 74 20 65 6e 74 | 72 79 29 0d 7b 0d 09 72 |,int ent|ry).{..r|
|00003160| 65 74 75 72 6e 20 47 65 | 74 4c 75 6d 69 6e 61 6e |eturn Ge|tLuminan|
|00003170| 63 65 28 4e 55 4c 4c 2c | 4c 50 2c 65 6e 74 72 79 |ce(NULL,|LP,entry|
|00003180| 29 3b 0d 7d 0d 0d 69 6e | 74 20 4c 54 6f 45 28 4c |);.}..in|t LToE(L|
|00003190| 75 6d 69 6e 61 6e 63 65 | 52 65 63 6f 72 64 20 2a |uminance|Record *|
|000031a0| 4c 50 2c 64 6f 75 62 6c | 65 20 4c 2c 69 6e 74 20 |LP,doubl|e L,int |
|000031b0| 66 69 72 73 74 45 6e 74 | 72 79 2c 69 6e 74 20 6c |firstEnt|ry,int l|
|000031c0| 61 73 74 45 6e 74 72 79 | 29 0d 2f 2f 52 65 74 75 |astEntry|).//Retu|
|000031d0| 72 6e 73 20 74 68 65 20 | 69 6e 64 65 78 20 6f 66 |rns the |index of|
|000031e0| 20 74 68 65 20 74 61 62 | 6c 65 20 65 6e 74 72 79 | the tab|le entry|
|000031f0| 20 69 6e 20 73 70 65 63 | 69 66 69 65 64 20 72 61 | in spec|ified ra|
|00003200| 6e 67 65 20 77 69 74 68 | 20 6c 75 6d 69 6e 61 6e |nge with| luminan|
|00003210| 63 65 20 63 6c 6f 73 65 | 73 74 20 74 6f 20 4c 2e |ce close|st to L.|
|00003220| 0d 7b 0d 09 69 6e 74 20 | 69 2c 65 6e 74 72 79 3b |.{..int |i,entry;|
|00003230| 0d 09 64 6f 75 62 6c 65 | 20 64 4c 2c 6c 61 74 65 |..double| dL,late|
|00003240| 73 74 44 4c 3b 0d 09 0d | 09 6c 61 74 65 73 74 44 |stDL;...|.latestD|
|00003250| 4c 3d 49 4e 46 3b 0d 09 | 65 6e 74 72 79 3d 30 3b |L=INF;..|entry=0;|
|00003260| 0d 09 66 6f 72 28 69 3d | 66 69 72 73 74 45 6e 74 |..for(i=|firstEnt|
|00003270| 72 79 3b 69 3c 3d 6c 61 | 73 74 45 6e 74 72 79 3b |ry;i<=la|stEntry;|
|00003280| 69 2b 2b 29 7b 0d 09 09 | 64 4c 3d 66 61 62 73 28 |i++){...|dL=fabs(|
|00003290| 4c 2d 47 65 74 4c 75 6d | 69 6e 61 6e 63 65 28 4e |L-GetLum|inance(N|
|000032a0| 55 4c 4c 2c 4c 50 2c 69 | 29 29 3b 0d 09 09 69 66 |ULL,LP,i|));...if|
|000032b0| 28 64 4c 3c 6c 61 74 65 | 73 74 44 4c 29 7b 0d 09 |(dL<late|stDL){..|
|000032c0| 09 09 65 6e 74 72 79 3d | 69 3b 0d 09 09 09 6c 61 |..entry=|i;....la|
|000032d0| 74 65 73 74 44 4c 3d 64 | 4c 3b 0d 09 09 7d 0d 09 |testDL=d|L;...}..|
|000032e0| 7d 0d 09 72 65 74 75 72 | 6e 20 65 6e 74 72 79 3b |}..retur|n entry;|
|000032f0| 0d 7d 0d 0d 69 6e 74 20 | 4c 54 6f 45 4f 72 64 65 |.}..int |LToEOrde|
|00003300| 72 65 64 28 4c 75 6d 69 | 6e 61 6e 63 65 52 65 63 |red(Lumi|nanceRec|
|00003310| 6f 72 64 20 2a 4c 50 2c | 64 6f 75 62 6c 65 20 4c |ord *LP,|double L|
|00003320| 2c 69 6e 74 20 66 69 72 | 73 74 45 6e 74 72 79 2c |,int fir|stEntry,|
|00003330| 69 6e 74 20 6c 61 73 74 | 45 6e 74 72 79 29 0d 2f |int last|Entry)./|
|00003340| 2a 0d 52 65 74 75 72 6e | 73 20 74 68 65 20 69 6e |*.Return|s the in|
|00003350| 64 65 78 20 6f 66 20 74 | 68 65 20 74 61 62 6c 65 |dex of t|he table|
|00003360| 20 65 6e 74 72 79 20 69 | 6e 20 73 70 65 63 69 66 | entry i|n specif|
|00003370| 69 65 64 20 72 61 6e 67 | 65 20 77 69 74 68 20 6c |ied rang|e with l|
|00003380| 75 6d 69 6e 61 6e 63 65 | 20 63 6c 6f 73 65 73 74 |uminance| closest|
|00003390| 20 74 6f 20 4c 2e 0d 41 | 73 73 75 6d 65 73 20 6f | to L..A|ssumes o|
|000033a0| 72 64 65 72 65 64 20 74 | 61 62 6c 65 20 66 72 6f |rdered t|able fro|
|000033b0| 6d 20 66 69 72 73 74 45 | 6e 74 72 79 20 74 6f 20 |m firstE|ntry to |
|000033c0| 6c 61 73 74 45 6e 74 72 | 79 2c 20 65 69 74 68 65 |lastEntr|y, eithe|
|000033d0| 72 20 69 6e 63 72 65 61 | 73 69 6e 67 20 6f 72 20 |r increa|sing or |
|000033e0| 64 65 63 72 65 61 73 69 | 6e 67 2e 0d 52 65 74 75 |decreasi|ng..Retu|
|000033f0| 72 6e 65 64 20 65 6e 74 | 72 79 20 69 73 20 67 75 |rned ent|ry is gu|
|00003400| 61 72 61 6e 74 65 65 64 | 20 74 6f 20 62 65 20 69 |aranteed| to be i|
|00003410| 6e 20 74 68 65 20 72 61 | 6e 67 65 20 66 69 72 73 |n the ra|nge firs|
|00003420| 74 45 6e 74 72 79 2e 2e | 2e 6c 61 73 74 45 6e 74 |tEntry..|.lastEnt|
|00003430| 72 79 2e 0d 42 61 73 65 | 64 20 6f 6e 20 4e 75 6d |ry..Base|d on Num|
|00003440| 65 72 69 63 61 6c 20 52 | 65 63 69 70 65 73 20 22 |erical R|ecipes "|
|00003450| 6c 6f 63 61 74 65 2e 63 | 22 2c 20 70 61 67 65 20 |locate.c|", page |
|00003460| 31 31 37 0d 2a 2f 0d 7b | 0d 09 72 65 67 69 73 74 |117.*/.{|..regist|
|00003470| 65 72 20 69 6e 74 20 6c | 6f 77 65 72 2c 6d 69 64 |er int l|ower,mid|
|00003480| 64 6c 65 2c 75 70 70 65 | 72 3b 0d 09 72 65 67 69 |dle,uppe|r;..regi|
|00003490| 73 74 65 72 20 64 6f 75 | 62 6c 65 20 4c 4c 6f 77 |ster dou|ble LLow|
|000034a0| 65 72 2c 4c 4d 69 64 64 | 6c 65 2c 4c 55 70 70 65 |er,LMidd|le,LUppe|
|000034b0| 72 3b 0d 09 69 6e 74 20 | 61 73 63 65 6e 64 3b 0d |r;..int |ascend;.|
|000034c0| 09 0d 09 6c 6f 77 65 72 | 3d 66 69 72 73 74 45 6e |...lower|=firstEn|
|000034d0| 74 72 79 3b 0d 09 75 70 | 70 65 72 3d 6c 61 73 74 |try;..up|per=last|
|000034e0| 45 6e 74 72 79 3b 0d 09 | 4c 4c 6f 77 65 72 3d 47 |Entry;..|LLower=G|
|000034f0| 65 74 4c 75 6d 69 6e 61 | 6e 63 65 28 4e 55 4c 4c |etLumina|nce(NULL|
|00003500| 2c 4c 50 2c 6c 6f 77 65 | 72 29 3b 0d 09 4c 55 70 |,LP,lowe|r);..LUp|
|00003510| 70 65 72 3d 47 65 74 4c | 75 6d 69 6e 61 6e 63 65 |per=GetL|uminance|
|00003520| 28 4e 55 4c 4c 2c 4c 50 | 2c 75 70 70 65 72 29 3b |(NULL,LP|,upper);|
|00003530| 0d 09 61 73 63 65 6e 64 | 3d 28 4c 55 70 70 65 72 |..ascend|=(LUpper|
|00003540| 3e 4c 4c 6f 77 65 72 29 | 3b 0d 09 77 68 69 6c 65 |>LLower)|;..while|
|00003550| 28 75 70 70 65 72 2d 6c | 6f 77 65 72 3e 31 29 7b |(upper-l|ower>1){|
|00003560| 0d 09 09 6d 69 64 64 6c | 65 3d 28 75 70 70 65 72 |...middl|e=(upper|
|00003570| 2b 6c 6f 77 65 72 29 2f | 32 3b 0d 09 09 4c 4d 69 |+lower)/|2;...LMi|
|00003580| 64 64 6c 65 3d 47 65 74 | 4c 75 6d 69 6e 61 6e 63 |ddle=Get|Luminanc|
|00003590| 65 28 4e 55 4c 4c 2c 4c | 50 2c 6d 69 64 64 6c 65 |e(NULL,L|P,middle|
|000035a0| 29 3b 0d 09 09 69 66 28 | 4c 3e 4c 4d 69 64 64 6c |);...if(|L>LMiddl|
|000035b0| 65 20 3d 3d 20 61 73 63 | 65 6e 64 29 7b 0d 09 09 |e == asc|end){...|
|000035c0| 09 6c 6f 77 65 72 3d 6d | 69 64 64 6c 65 3b 0d 09 |.lower=m|iddle;..|
|000035d0| 09 09 4c 4c 6f 77 65 72 | 3d 4c 4d 69 64 64 6c 65 |..LLower|=LMiddle|
|000035e0| 3b 0d 09 09 7d 0d 09 09 | 65 6c 73 65 7b 0d 09 09 |;...}...|else{...|
|000035f0| 09 75 70 70 65 72 3d 6d | 69 64 64 6c 65 3b 0d 09 |.upper=m|iddle;..|
|00003600| 09 09 4c 55 70 70 65 72 | 3d 4c 4d 69 64 64 6c 65 |..LUpper|=LMiddle|
|00003610| 3b 0d 09 09 7d 0d 09 7d | 0d 09 69 66 28 4c 2d 4c |;...}..}|..if(L-L|
|00003620| 4c 6f 77 65 72 3c 4c 55 | 70 70 65 72 2d 4c 20 3d |Lower<LU|pper-L =|
|00003630| 3d 20 61 73 63 65 6e 64 | 29 72 65 74 75 72 6e 20 |= ascend|)return |
|00003640| 6c 6f 77 65 72 3b 0d 09 | 65 6c 73 65 20 72 65 74 |lower;..|else ret|
|00003650| 75 72 6e 20 75 70 70 65 | 72 3b 0d 7d 0d 64 6f 75 |urn uppe|r;.}.dou|
|00003660| 62 6c 65 20 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 |ble SetL|uminance|
|00003670| 28 47 44 48 61 6e 64 6c | 65 20 64 65 76 69 63 65 |(GDHandl|e device|
|00003680| 2c 4c 75 6d 69 6e 61 6e | 63 65 52 65 63 6f 72 64 |,Luminan|ceRecord|
|00003690| 20 2a 4c 50 0d 09 2c 69 | 6e 74 20 74 68 65 45 6e | *LP..,i|nt theEn|
|000036a0| 74 72 79 2c 64 6f 75 62 | 6c 65 20 6c 75 6d 69 6e |try,doub|le lumin|
|000036b0| 61 6e 63 65 0d 09 2c 64 | 6f 75 62 6c 65 20 6c 6f |ance..,d|ouble lo|
|000036c0| 77 4c 75 6d 69 6e 61 6e | 63 65 2c 64 6f 75 62 6c |wLuminan|ce,doubl|
|000036d0| 65 20 68 69 67 68 4c 75 | 6d 69 6e 61 6e 63 65 29 |e highLu|minance)|
|000036e0| 0d 2f 2a 0d 53 65 74 20 | 6f 6e 65 20 65 6e 74 72 |./*.Set |one entr|
|000036f0| 79 20 69 6e 20 74 68 65 | 20 43 6f 6c 6f 72 53 70 |y in the| ColorSp|
|00003700| 65 63 20 74 61 62 6c 65 | 20 28 61 6e 64 20 74 68 |ec table| (and th|
|00003710| 65 20 63 6c 75 74 20 69 | 66 20 64 65 76 69 63 65 |e clut i|f device|
|00003720| 20 69 73 20 6e 6f 74 20 | 4e 55 4c 4c 29 20 74 6f | is not |NULL) to|
|00003730| 0d 61 20 73 70 65 63 69 | 66 69 65 64 20 6c 75 6d |.a speci|fied lum|
|00003740| 69 6e 61 6e 63 65 2e 20 | 49 74 27 73 20 6f 6b 20 |inance. |It's ok |
|00003750| 66 6f 72 20 6c 6f 77 4c | 75 6d 69 6e 61 6e 63 65 |for lowL|uminance|
|00003760| 20 74 6f 20 62 65 20 67 | 72 65 61 74 65 72 20 74 | to be g|reater t|
|00003770| 68 61 6e 20 68 69 67 68 | 4c 75 6d 69 6e 61 6e 63 |han high|Luminanc|
|00003780| 65 3b 20 0d 74 68 65 79 | 20 73 74 69 6c 6c 20 64 |e; .they| still d|
|00003790| 65 73 69 67 6e 61 74 65 | 20 61 20 72 61 6e 67 65 |esignate| a range|
|000037a0| 2e 0d 2a 2f 0d 7b 0d 09 | 46 49 58 45 44 20 5f 6c |..*/.{..|FIXED _l|
|000037b0| 75 6d 69 6e 61 6e 63 65 | 3b 0d 09 0d 09 69 66 28 |uminance|;....if(|
|000037c0| 74 68 65 45 6e 74 72 79 | 3c 30 20 7c 7c 20 74 68 |theEntry|<0 || th|
|000037d0| 65 45 6e 74 72 79 3e 3d | 43 4f 4c 4f 52 53 20 0d |eEntry>=|COLORS .|
|000037e0| 09 09 7c 7c 20 64 65 76 | 69 63 65 21 3d 4e 55 4c |..|| dev|ice!=NUL|
|000037f0| 4c 20 26 26 20 74 68 65 | 45 6e 74 72 79 3e 3d 47 |L && the|Entry>=G|
|00003800| 44 43 4c 55 54 53 49 5a | 45 28 64 65 76 69 63 65 |DCLUTSIZ|E(device|
|00003810| 29 29 0d 09 09 09 50 72 | 69 6e 74 66 45 78 69 74 |))....Pr|intfExit|
|00003820| 28 22 5c 30 30 37 53 65 | 74 4c 75 6d 69 6e 61 6e |("\007Se|tLuminan|
|00003830| 63 65 3a 20 69 6c 6c 65 | 67 61 6c 20 65 6e 74 72 |ce: ille|gal entr|
|00003840| 79 20 25 64 5c 6e 22 2c | 74 68 65 45 6e 74 72 79 |y %d\n",|theEntry|
|00003850| 29 3b 0d 09 0d 09 53 65 | 74 4c 75 6d 69 6e 61 6e |);....Se|tLuminan|
|00003860| 63 65 52 61 6e 67 65 28 | 4c 50 2c 6c 6f 77 4c 75 |ceRange(|LP,lowLu|
|00003870| 6d 69 6e 61 6e 63 65 2c | 68 69 67 68 4c 75 6d 69 |minance,|highLumi|
|00003880| 6e 61 6e 63 65 29 3b 0d | 09 5f 6c 75 6d 69 6e 61 |nance);.|._lumina|
|00003890| 6e 63 65 3d 44 6f 75 62 | 6c 65 54 6f 46 69 78 28 |nce=Doub|leToFix(|
|000038a0| 6c 75 6d 69 6e 61 6e 63 | 65 29 3b 0d 09 5f 53 65 |luminanc|e);.._Se|
|000038b0| 74 4c 75 6d 69 6e 61 6e | 63 65 28 4c 50 2c 74 68 |tLuminan|ce(LP,th|
|000038c0| 65 45 6e 74 72 79 2c 5f | 6c 75 6d 69 6e 61 6e 63 |eEntry,_|luminanc|
|000038d0| 65 29 3b 0d 09 69 66 28 | 64 65 76 69 63 65 20 21 |e);..if(|device !|
|000038e0| 3d 20 4e 55 4c 4c 29 4c | 6f 61 64 4c 75 6d 69 6e |= NULL)L|oadLumin|
|000038f0| 61 6e 63 65 73 28 64 65 | 76 69 63 65 2c 4c 50 2c |ances(de|vice,LP,|
|00003900| 74 68 65 45 6e 74 72 79 | 2c 74 68 65 45 6e 74 72 |theEntry|,theEntr|
|00003910| 79 29 3b 0d 09 72 65 74 | 75 72 6e 20 46 69 78 54 |y);..ret|urn FixT|
|00003920| 6f 44 6f 75 62 6c 65 28 | 5f 54 6f 6c 65 72 61 6e |oDouble(|_Toleran|
|00003930| 63 65 28 4c 50 2c 5f 6c | 75 6d 69 6e 61 6e 63 65 |ce(LP,_l|uminance|
|00003940| 29 29 3b 0d 7d 0d 0d 64 | 6f 75 62 6c 65 20 53 65 |));.}..d|ouble Se|
|00003950| 74 4c 75 6d 69 6e 61 6e | 63 65 73 28 47 44 48 61 |tLuminan|ces(GDHa|
|00003960| 6e 64 6c 65 20 64 65 76 | 69 63 65 2c 4c 75 6d 69 |ndle dev|ice,Lumi|
|00003970| 6e 61 6e 63 65 52 65 63 | 6f 72 64 20 2a 4c 50 0d |nanceRec|ord *LP.|
|00003980| 09 2c 69 6e 74 20 66 69 | 72 73 74 45 6e 74 72 79 |.,int fi|rstEntry|
|00003990| 2c 69 6e 74 20 6c 61 73 | 74 45 6e 74 72 79 0d 09 |,int las|tEntry..|
|000039a0| 2c 64 6f 75 62 6c 65 20 | 66 69 72 73 74 4c 75 6d |,double |firstLum|
|000039b0| 69 6e 61 6e 63 65 2c 64 | 6f 75 62 6c 65 20 6c 61 |inance,d|ouble la|
|000039c0| 73 74 4c 75 6d 69 6e 61 | 6e 63 65 29 0d 2f 2a 0d |stLumina|nce)./*.|
|000039d0| 53 65 74 20 61 20 73 65 | 72 69 65 73 20 6f 66 20 |Set a se|ries of |
|000039e0| 65 6e 74 72 69 65 73 20 | 69 6e 20 74 68 65 20 43 |entries |in the C|
|000039f0| 6f 6c 6f 72 53 70 65 63 | 20 74 61 62 6c 65 20 28 |olorSpec| table (|
|00003a00| 61 6e 64 20 74 68 65 20 | 63 6c 75 74 20 69 66 20 |and the |clut if |
|00003a10| 64 65 76 69 63 65 20 69 | 73 20 6e 6f 74 20 4e 55 |device i|s not NU|
|00003a20| 4c 4c 29 0d 74 6f 20 61 | 20 6c 69 6e 65 61 72 20 |LL).to a| linear |
|00003a30| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 6c 75 6d 69 |sequence| of lumi|
|00003a40| 6e 61 6e 63 65 73 2e 20 | 41 73 73 75 6d 65 20 74 |nances. |Assume t|
|00003a50| 68 69 73 20 69 73 20 74 | 68 65 20 65 6e 74 69 72 |his is t|he entir|
|00003a60| 65 20 6c 75 6d 69 6e 61 | 6e 63 65 20 72 61 6e 67 |e lumina|nce rang|
|00003a70| 65 20 6f 66 20 0d 69 6e | 74 65 72 65 73 74 2e 0d |e of .in|terest..|
|00003a80| 2a 2f 0d 7b 0d 09 72 65 | 74 75 72 6e 20 53 65 74 |*/.{..re|turn Set|
|00003a90| 4c 75 6d 69 6e 61 6e 63 | 65 73 41 6e 64 52 61 6e |Luminanc|esAndRan|
|00003aa0| 67 65 28 64 65 76 69 63 | 65 2c 4c 50 2c 66 69 72 |ge(devic|e,LP,fir|
|00003ab0| 73 74 45 6e 74 72 79 2c | 6c 61 73 74 45 6e 74 72 |stEntry,|lastEntr|
|00003ac0| 79 0d 09 09 2c 66 69 72 | 73 74 4c 75 6d 69 6e 61 |y...,fir|stLumina|
|00003ad0| 6e 63 65 2c 6c 61 73 74 | 4c 75 6d 69 6e 61 6e 63 |nce,last|Luminanc|
|00003ae0| 65 2c 66 69 72 73 74 4c | 75 6d 69 6e 61 6e 63 65 |e,firstL|uminance|
|00003af0| 2c 6c 61 73 74 4c 75 6d | 69 6e 61 6e 63 65 29 3b |,lastLum|inance);|
|00003b00| 0d 7d 0d 0d 64 6f 75 62 | 6c 65 20 53 65 74 4c 75 |.}..doub|le SetLu|
|00003b10| 6d 69 6e 61 6e 63 65 73 | 41 6e 64 52 61 6e 67 65 |minances|AndRange|
|00003b20| 28 47 44 48 61 6e 64 6c | 65 20 64 65 76 69 63 65 |(GDHandl|e device|
|00003b30| 2c 4c 75 6d 69 6e 61 6e | 63 65 52 65 63 6f 72 64 |,Luminan|ceRecord|
|00003b40| 20 2a 4c 50 0d 09 2c 69 | 6e 74 20 66 69 72 73 74 | *LP..,i|nt first|
|00003b50| 45 6e 74 72 79 2c 69 6e | 74 20 6c 61 73 74 45 6e |Entry,in|t lastEn|
|00003b60| 74 72 79 0d 09 2c 64 6f | 75 62 6c 65 20 66 69 72 |try..,do|uble fir|
|00003b70| 73 74 4c 75 6d 69 6e 61 | 6e 63 65 2c 64 6f 75 62 |stLumina|nce,doub|
|00003b80| 6c 65 20 6c 61 73 74 4c | 75 6d 69 6e 61 6e 63 65 |le lastL|uminance|
|00003b90| 0d 09 2c 64 6f 75 62 6c | 65 20 6c 6f 77 4c 75 6d |..,doubl|e lowLum|
|00003ba0| 69 6e 61 6e 63 65 2c 64 | 6f 75 62 6c 65 20 68 69 |inance,d|ouble hi|
|00003bb0| 67 68 4c 75 6d 69 6e 61 | 6e 63 65 29 0d 2f 2a 0d |ghLumina|nce)./*.|
|00003bc0| 53 65 74 20 61 20 73 65 | 72 69 65 73 20 6f 66 20 |Set a se|ries of |
|00003bd0| 65 6e 74 72 69 65 73 20 | 69 6e 20 74 68 65 20 43 |entries |in the C|
|00003be0| 6f 6c 6f 72 53 70 65 63 | 20 74 61 62 6c 65 20 28 |olorSpec| table (|
|00003bf0| 61 6e 64 20 74 68 65 20 | 63 6c 75 74 20 69 66 20 |and the |clut if |
|00003c00| 64 65 76 69 63 65 20 69 | 73 20 6e 6f 74 0d 4e 55 |device i|s not.NU|
|00003c10| 4c 4c 29 20 74 6f 20 61 | 20 6c 69 6e 65 61 72 20 |LL) to a| linear |
|00003c20| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 6c 75 6d 69 |sequence| of lumi|
|00003c30| 6e 61 6e 63 65 73 2e 20 | 55 73 65 73 20 6c 61 73 |nances. |Uses las|
|00003c40| 74 20 74 77 6f 20 61 72 | 67 75 6d 65 6e 74 73 20 |t two ar|guments |
|00003c50| 74 6f 20 73 65 74 20 74 | 68 65 0d 6c 75 6d 69 6e |to set t|he.lumin|
|00003c60| 61 6e 63 65 20 72 61 6e | 67 65 2e 0d 0d 49 20 69 |ance ran|ge...I i|
|00003c70| 6e 74 72 6f 64 75 63 65 | 64 20 61 20 73 74 61 63 |ntroduce|d a stac|
|00003c80| 6b 2d 73 70 61 63 65 20 | 63 68 65 63 6b 20 62 65 |k-space |check be|
|00003c90| 66 6f 72 65 20 63 61 6c | 6c 69 6e 67 20 5f 53 65 |fore cal|ling _Se|
|00003ca0| 74 4c 75 6d 69 6e 61 6e | 63 65 73 28 29 2c 20 73 |tLuminan|ces(), s|
|00003cb0| 69 6e 63 65 20 69 74 20 | 63 61 6c 6c 73 0d 69 74 |ince it |calls.it|
|00003cc0| 73 65 6c 66 20 72 65 63 | 75 72 73 69 76 65 6c 79 |self rec|ursively|
|00003cd0| 20 61 6e 64 20 6d 61 79 | 20 75 73 65 20 31 30 30 | and may| use 100|
|00003ce0| 30 20 62 79 74 65 73 20 | 61 6c 6c 20 74 6f 67 65 |0 bytes |all toge|
|00003cf0| 74 68 65 72 2e 20 48 6f | 77 65 76 65 72 2c 20 70 |ther. Ho|wever, p|
|00003d00| 72 69 6e 74 69 6e 67 20 | 61 6e 0d 65 72 72 6f 72 |rinting |an.error|
|00003d10| 20 6d 65 73 73 61 67 65 | 20 72 65 71 75 69 72 65 | message| require|
|00003d20| 73 20 61 74 20 6c 65 61 | 73 74 20 34 35 30 30 20 |s at lea|st 4500 |
|00003d30| 62 79 74 65 73 2e 20 53 | 6f 20 49 20 71 75 69 74 |bytes. S|o I quit|
|00003d40| 20 69 66 20 74 68 65 20 | 73 74 61 63 6b 20 67 65 | if the |stack ge|
|00003d50| 74 73 20 62 65 6c 6f 77 | 0d 36 30 30 30 2c 20 73 |ts below|.6000, s|
|00003d60| 6f 20 74 68 61 74 20 74 | 68 65 20 75 73 65 72 20 |o that t|he user |
|00003d70| 77 69 6c 6c 20 62 65 20 | 70 72 65 73 65 6e 74 65 |will be |presente|
|00003d80| 64 20 77 69 74 68 20 61 | 6e 20 75 6e 64 65 72 73 |d with a|n unders|
|00003d90| 74 61 6e 64 61 62 6c 65 | 20 65 72 72 6f 72 20 6d |tandable| error m|
|00003da0| 65 73 73 61 67 65 0d 72 | 61 74 68 65 72 20 74 68 |essage.r|ather th|
|00003db0| 61 6e 20 61 20 6d 79 73 | 74 65 72 69 6f 75 73 20 |an a mys|terious |
|00003dc0| 71 75 69 74 20 6f 72 20 | 63 72 61 73 68 2e 0d 2a |quit or |crash..*|
|00003dd0| 2f 0d 7b 0d 09 46 49 58 | 45 44 20 5f 74 6f 6c 65 |/.{..FIX|ED _tole|
|00003de0| 72 61 6e 63 65 2c 5f 74 | 2c 5f 64 4c 36 34 3b 0d |rance,_t|,_dL64;.|
|00003df0| 09 46 49 58 45 44 20 5f | 66 69 72 73 74 4c 2c 5f |.FIXED _|firstL,_|
|00003e00| 6c 61 73 74 4c 2c 5f 66 | 69 72 73 74 56 2c 5f 6c |lastL,_f|irstV,_l|
|00003e10| 61 73 74 56 3b 0d 09 0d | 09 69 66 28 66 69 72 73 |astV;...|.if(firs|
|00003e20| 74 45 6e 74 72 79 3c 30 | 20 7c 7c 20 66 69 72 73 |tEntry<0| || firs|
|00003e30| 74 45 6e 74 72 79 3e 6c | 61 73 74 45 6e 74 72 79 |tEntry>l|astEntry|
|00003e40| 20 7c 7c 20 6c 61 73 74 | 45 6e 74 72 79 3e 3d 43 | || last|Entry>=C|
|00003e50| 4f 4c 4f 52 53 20 0d 09 | 09 7c 7c 20 64 65 76 69 |OLORS ..|.|| devi|
|00003e60| 63 65 21 3d 4e 55 4c 4c | 20 26 26 20 6c 61 73 74 |ce!=NULL| && last|
|00003e70| 45 6e 74 72 79 3e 3d 47 | 44 43 4c 55 54 53 49 5a |Entry>=G|DCLUTSIZ|
|00003e80| 45 28 64 65 76 69 63 65 | 29 20 29 0d 09 09 50 72 |E(device|) )...Pr|
|00003e90| 69 6e 74 66 45 78 69 74 | 28 22 5c 30 30 37 53 65 |intfExit|("\007Se|
|00003ea0| 74 4c 75 6d 69 6e 61 6e | 63 65 73 41 6e 64 52 61 |tLuminan|cesAndRa|
|00003eb0| 6e 67 65 3a 20 69 6c 6c | 65 67 61 6c 20 65 6e 74 |nge: ill|egal ent|
|00003ec0| 72 69 65 73 20 25 64 20 | 25 64 5c 6e 22 2c 66 69 |ries %d |%d\n",fi|
|00003ed0| 72 73 74 45 6e 74 72 79 | 2c 6c 61 73 74 45 6e 74 |rstEntry|,lastEnt|
|00003ee0| 72 79 29 3b 0d 09 69 66 | 28 53 74 61 63 6b 53 70 |ry);..if|(StackSp|
|00003ef0| 61 63 65 28 29 3c 36 30 | 30 30 29 50 72 69 6e 74 |ace()<60|00)Print|
|00003f00| 66 45 78 69 74 28 22 53 | 65 74 4c 75 6d 69 6e 61 |fExit("S|etLumina|
|00003f10| 6e 63 65 73 41 6e 64 52 | 61 6e 67 65 3a 20 6e 6f |ncesAndR|ange: no|
|00003f20| 74 20 65 6e 6f 75 67 68 | 20 73 74 61 63 6b 20 73 |t enough| stack s|
|00003f30| 70 61 63 65 2e 5c 30 30 | 37 5c 6e 22 29 3b 0d 09 |pace.\00|7\n");..|
|00003f40| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 52 61 6e 67 |SetLumin|anceRang|
|00003f50| 65 28 4c 50 2c 6c 6f 77 | 4c 75 6d 69 6e 61 6e 63 |e(LP,low|Luminanc|
|00003f60| 65 2c 68 69 67 68 4c 75 | 6d 69 6e 61 6e 63 65 29 |e,highLu|minance)|
|00003f70| 3b 0d 09 5f 66 69 72 73 | 74 4c 3d 44 6f 75 62 6c |;.._firs|tL=Doubl|
|00003f80| 65 54 6f 46 69 78 28 66 | 69 72 73 74 4c 75 6d 69 |eToFix(f|irstLumi|
|00003f90| 6e 61 6e 63 65 29 3b 0d | 09 5f 6c 61 73 74 4c 3d |nance);.|._lastL=|
|00003fa0| 44 6f 75 62 6c 65 54 6f | 46 69 78 28 6c 61 73 74 |DoubleTo|Fix(last|
|00003fb0| 4c 75 6d 69 6e 61 6e 63 | 65 29 3b 0d 09 5f 66 69 |Luminanc|e);.._fi|
|00003fc0| 72 73 74 56 3d 5f 4c 54 | 6f 56 28 4c 50 2c 5f 66 |rstV=_LT|oV(LP,_f|
|00003fd0| 69 72 73 74 4c 20 2b 20 | 4c 50 2d 3e 5f 4c 4f 66 |irstL + |LP->_LOf|
|00003fe0| 66 73 65 74 29 3b 0d 09 | 5f 6c 61 73 74 56 3d 5f |fset);..|_lastV=_|
|00003ff0| 4c 54 6f 56 28 4c 50 2c | 5f 6c 61 73 74 4c 20 2b |LToV(LP,|_lastL +|
|00004000| 20 4c 50 2d 3e 5f 4c 4f | 66 66 73 65 74 29 3b 0d | LP->_LO|ffset);.|
|00004010| 09 69 66 28 6c 61 73 74 | 45 6e 74 72 79 20 21 3d |.if(last|Entry !=|
|00004020| 20 66 69 72 73 74 45 6e | 74 72 79 29 7b 0d 09 09 | firstEn|try){...|
|00004030| 23 69 66 20 46 41 53 54 | 5f 4c 55 4d 49 4e 41 4e |#if FAST|_LUMINAN|
|00004040| 43 45 0d 09 09 5f 64 4c | 36 34 3d 44 6f 75 62 6c |CE..._dL|64=Doubl|
|00004050| 65 54 6f 46 69 78 28 36 | 34 2e 30 2a 28 6c 61 73 |eToFix(6|4.0*(las|
|00004060| 74 4c 75 6d 69 6e 61 6e | 63 65 2d 66 69 72 73 74 |tLuminan|ce-first|
|00004070| 4c 75 6d 69 6e 61 6e 63 | 65 29 2f 28 6c 61 73 74 |Luminanc|e)/(last|
|00004080| 45 6e 74 72 79 2d 66 69 | 72 73 74 45 6e 74 72 79 |Entry-fi|rstEntry|
|00004090| 29 29 3b 0d 09 09 23 65 | 6c 73 65 0d 09 09 5f 64 |));...#e|lse..._d|
|000040a0| 4c 36 34 3d 44 6f 75 62 | 6c 65 54 6f 46 69 78 28 |L64=Doub|leToFix(|
|000040b0| 28 6c 61 73 74 4c 75 6d | 69 6e 61 6e 63 65 2d 66 |(lastLum|inance-f|
|000040c0| 69 72 73 74 4c 75 6d 69 | 6e 61 6e 63 65 29 2f 28 |irstLumi|nance)/(|
|000040d0| 6c 61 73 74 45 6e 74 72 | 79 2d 66 69 72 73 74 45 |lastEntr|y-firstE|
|000040e0| 6e 74 72 79 29 29 3b 0d | 09 09 23 65 6e 64 69 66 |ntry));.|..#endif|
|000040f0| 0d 09 7d 65 6c 73 65 20 | 5f 64 4c 36 34 3d 30 3b |..}else |_dL64=0;|
|00004100| 0d 09 5f 53 65 74 4c 75 | 6d 69 6e 61 6e 63 65 73 |.._SetLu|minances|
|00004110| 28 4c 50 2c 66 69 72 73 | 74 45 6e 74 72 79 2c 6c |(LP,firs|tEntry,l|
|00004120| 61 73 74 45 6e 74 72 79 | 2c 5f 66 69 72 73 74 4c |astEntry|,_firstL|
|00004130| 2c 5f 64 4c 36 34 2c 5f | 66 69 72 73 74 56 2c 5f |,_dL64,_|firstV,_|
|00004140| 6c 61 73 74 56 29 3b 0d | 09 69 66 28 64 65 76 69 |lastV);.|.if(devi|
|00004150| 63 65 20 21 3d 20 4e 55 | 4c 4c 29 4c 6f 61 64 4c |ce != NU|LL)LoadL|
|00004160| 75 6d 69 6e 61 6e 63 65 | 73 28 64 65 76 69 63 65 |uminance|s(device|
|00004170| 2c 4c 50 2c 66 69 72 73 | 74 45 6e 74 72 79 2c 6c |,LP,firs|tEntry,l|
|00004180| 61 73 74 45 6e 74 72 79 | 29 3b 09 0d 09 0d 09 2f |astEntry|);...../|
|00004190| 2a 20 71 75 69 63 6b 20 | 61 6e 64 20 64 69 72 74 |* quick |and dirt|
|000041a0| 79 20 65 73 74 69 6d 61 | 74 65 20 6f 66 20 74 6f |y estima|te of to|
|000041b0| 6c 65 72 61 6e 63 65 20 | 2a 2f 0d 09 5f 74 6f 6c |lerance |*/.._tol|
|000041c0| 65 72 61 6e 63 65 3d 4c | 50 2d 3e 4c 2e 5f 4c 75 |erance=L|P->L._Lu|
|000041d0| 5b 30 5d 20 2d 20 5f 66 | 69 72 73 74 4c 3b 0d 09 |[0] - _f|irstL;..|
|000041e0| 5f 74 3d 5f 6c 61 73 74 | 4c 20 2d 20 4c 50 2d 3e |_t=_last|L - LP->|
|000041f0| 4c 2e 5f 4c 75 5b 4c 55 | 4d 49 4e 41 4e 43 45 53 |L._Lu[LU|MINANCES|
|00004200| 5f 49 4e 5f 54 41 42 4c | 45 2d 31 5d 3b 0d 09 69 |_IN_TABL|E-1];..i|
|00004210| 66 28 5f 74 6f 6c 65 72 | 61 6e 63 65 3c 5f 74 29 |f(_toler|ance<_t)|
|00004220| 5f 74 6f 6c 65 72 61 6e | 63 65 3d 5f 74 3b 0d 09 |_toleran|ce=_t;..|
|00004230| 69 66 28 5f 74 6f 6c 65 | 72 61 6e 63 65 3c 30 29 |if(_tole|rance<0)|
|00004240| 5f 74 6f 6c 65 72 61 6e | 63 65 3d 30 3b 0d 09 5f |_toleran|ce=0;.._|
|00004250| 74 6f 6c 65 72 61 6e 63 | 65 2b 3d 4c 50 2d 3e 5f |toleranc|e+=LP->_|
|00004260| 74 6f 6c 65 72 61 6e 63 | 65 3b 0d 09 72 65 74 75 |toleranc|e;..retu|
|00004270| 72 6e 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 5f |rn FixTo|Double(_|
|00004280| 74 6f 6c 65 72 61 6e 63 | 65 29 3b 09 2f 2a 20 65 |toleranc|e);./* e|
|00004290| 73 74 69 6d 61 74 65 20 | 6f 66 20 6d 61 78 20 65 |stimate |of max e|
|000042a0| 72 72 6f 72 20 69 6e 20 | c6 4c 20 2a 2f 0d 7d 0d |rror in |.L */.}.|
|000042b0| 0d 76 6f 69 64 20 5f 53 | 65 74 4c 75 6d 69 6e 61 |.void _S|etLumina|
|000042c0| 6e 63 65 73 28 4c 75 6d | 69 6e 61 6e 63 65 52 65 |nces(Lum|inanceRe|
|000042d0| 63 6f 72 64 20 2a 4c 50 | 74 72 2c 69 6e 74 20 66 |cord *LP|tr,int f|
|000042e0| 69 72 73 74 2c 69 6e 74 | 20 6c 61 73 74 0d 09 2c |irst,int| last..,|
|000042f0| 46 49 58 45 44 20 5f 66 | 69 72 73 74 4c 2c 46 49 |FIXED _f|irstL,FI|
|00004300| 58 45 44 20 5f 64 4c 36 | 34 2c 46 49 58 45 44 20 |XED _dL6|4,FIXED |
|00004310| 5f 66 69 72 73 74 56 2c | 46 49 58 45 44 20 5f 6c |_firstV,|FIXED _l|
|00004320| 61 73 74 56 29 0d 2f 2a | 0d 54 68 69 73 20 72 6f |astV)./*|.This ro|
|00004330| 75 74 69 6e 65 20 65 6c | 69 6d 69 6e 61 74 65 73 |utine el|iminates|
|00004340| 20 6d 6f 73 74 20 6f 66 | 20 74 68 65 20 74 68 65 | most of| the the|
|00004350| 20 73 6c 6f 77 20 5f 4c | 54 6f 56 28 29 20 74 61 | slow _L|ToV() ta|
|00004360| 62 6c 65 20 6c 6f 6f 6b | 75 70 73 20 61 6e 64 0d |ble look|ups and.|
|00004370| 69 6e 74 65 72 70 6f 6c | 61 74 69 6f 6e 73 20 62 |interpol|ations b|
|00004380| 79 20 61 73 73 75 6d 69 | 6e 67 20 74 68 61 74 20 |y assumi|ng that |
|00004390| 74 68 65 20 67 61 6d 6d | 61 20 66 75 6e 63 74 69 |the gamm|a functi|
|000043a0| 6f 6e 20 69 73 20 73 6d | 6f 6f 74 68 20 65 6e 6f |on is sm|ooth eno|
|000043b0| 75 67 68 20 74 68 61 74 | 20 77 65 20 6d 61 79 0d |ugh that| we may.|
|000043c0| 6c 69 6e 65 61 72 6c 79 | 20 69 6e 74 65 72 70 6f |linearly| interpo|
|000043d0| 6c 61 74 65 20 6f 76 65 | 72 20 61 6e 79 20 69 6e |late ove|r any in|
|000043e0| 74 65 72 76 61 6c 20 6f | 66 20 56 20 6e 6f 20 77 |terval o|f V no w|
|000043f0| 69 64 65 72 20 74 68 61 | 6e 20 4c 49 4e 45 41 52 |ider tha|n LINEAR|
|00004400| 5f 56 5f 44 4f 4d 41 49 | 4e 2e 20 53 69 6e 63 65 |_V_DOMAI|N. Since|
|00004410| 0d 74 68 65 20 67 61 6d | 6d 61 20 66 75 6e 63 74 |.the gam|ma funct|
|00004420| 69 6f 6e 20 69 73 20 72 | 6f 75 67 68 6c 79 20 70 |ion is r|oughly p|
|00004430| 61 72 61 62 6f 6c 69 63 | 2c 20 74 68 65 20 63 6f |arabolic|, the co|
|00004440| 6e 73 65 71 75 65 6e 74 | 20 65 72 72 6f 72 20 69 |nsequent| error i|
|00004450| 6e 20 4c 20 77 69 6c 6c | 20 62 65 0d 70 72 6f 70 |n L will| be.prop|
|00004460| 6f 72 74 69 6f 6e 61 6c | 20 74 6f 20 74 68 65 20 |ortional| to the |
|00004470| 73 71 75 61 72 65 20 6f | 66 20 4c 49 4e 45 41 52 |square o|f LINEAR|
|00004480| 5f 56 5f 44 4f 4d 41 49 | 4e 2c 20 61 6e 64 20 69 |_V_DOMAI|N, and i|
|00004490| 6e 64 65 70 65 6e 64 65 | 6e 74 20 6f 66 20 77 68 |ndepende|nt of wh|
|000044a0| 65 72 65 20 74 68 69 73 | 0d 69 6e 74 65 72 76 61 |ere this|.interva|
|000044b0| 6c 20 69 73 20 61 6c 6f | 6e 67 20 56 2e 20 53 69 |l is alo|ng V. Si|
|000044c0| 6e 63 65 20 77 65 27 72 | 65 20 69 6e 73 63 72 69 |nce we'r|e inscri|
|000044d0| 62 69 6e 67 20 73 74 72 | 61 69 67 68 74 20 6c 69 |bing str|aight li|
|000044e0| 6e 65 20 73 65 67 6d 65 | 6e 74 73 20 69 6e 20 61 |ne segme|nts in a|
|000044f0| 0d 70 6f 73 69 74 69 76 | 65 6c 79 20 61 63 63 65 |.positiv|ely acce|
|00004500| 6c 65 72 61 74 69 6e 67 | 20 67 61 6d 6d 61 20 66 |lerating| gamma f|
|00004510| 75 6e 63 74 69 6f 6e 2c | 20 77 65 20 77 69 6c 6c |unction,| we will|
|00004520| 20 6f 76 65 72 65 73 74 | 69 6d 61 74 65 20 6c 75 | overest|imate lu|
|00004530| 6d 69 6e 61 6e 63 65 2c | 20 61 6e 64 0d 63 6f 6e |minance,| and.con|
|00004540| 73 65 71 75 65 6e 74 6c | 79 20 56 20 77 69 6c 6c |sequentl|y V will|
|00004550| 20 62 65 20 74 6f 6f 20 | 6c 6f 77 2e 20 54 68 65 | be too |low. The|
|00004560| 20 65 72 72 6f 72 20 77 | 69 6c 6c 20 62 65 20 67 | error w|ill be g|
|00004570| 72 65 61 74 65 73 74 20 | 61 74 20 74 68 65 20 6d |reatest |at the m|
|00004580| 69 64 64 6c 65 20 6f 66 | 20 65 61 63 68 0d 6c 69 |iddle of| each.li|
|00004590| 6e 65 61 72 6c 79 20 69 | 6e 74 65 72 70 6f 6c 61 |nearly i|nterpola|
|000045a0| 74 65 64 20 56 20 69 6e | 74 65 72 76 61 6c 2e 0d |ted V in|terval..|
|000045b0| 0d 49 66 20 74 68 65 20 | 72 65 71 75 65 73 74 65 |.If the |requeste|
|000045c0| 64 20 56 20 69 6e 74 65 | 72 76 61 6c 20 69 73 20 |d V inte|rval is |
|000045d0| 6c 61 72 67 65 72 20 74 | 68 61 6e 20 4c 49 4e 45 |larger t|han LINE|
|000045e0| 41 52 5f 56 5f 44 4f 4d | 41 49 4e 2c 20 74 68 65 |AR_V_DOM|AIN, the|
|000045f0| 6e 20 69 74 20 69 73 20 | 73 70 6c 69 74 0d 69 6e |n it is |split.in|
|00004600| 74 6f 20 74 77 6f 20 69 | 6e 74 65 72 76 61 6c 73 |to two i|ntervals|
|00004610| 20 62 79 20 6d 61 6b 69 | 6e 67 20 61 20 70 61 69 | by maki|ng a pai|
|00004620| 72 20 6f 66 20 72 65 63 | 75 72 73 69 76 65 20 63 |r of rec|ursive c|
|00004630| 61 6c 6c 73 2e 20 4c 49 | 4e 45 41 52 5f 56 5f 44 |alls. LI|NEAR_V_D|
|00004640| 4f 4d 41 49 4e 20 69 73 | 0d 64 65 66 69 6e 65 64 |OMAIN is|.defined|
|00004650| 20 69 6e 20 4c 75 6d 69 | 6e 61 6e 63 65 2e 68 2e | in Lumi|nance.h.|
|00004660| 20 49 20 73 75 67 67 65 | 73 74 20 61 20 76 61 6c | I sugge|st a val|
|00004670| 75 65 20 6f 66 20 34 2c | 20 62 75 74 20 69 74 20 |ue of 4,| but it |
|00004680| 6d 61 79 20 62 65 20 73 | 65 74 20 6c 61 72 67 65 |may be s|et large|
|00004690| 72 20 74 6f 0d 61 74 74 | 61 69 6e 20 73 6c 69 67 |r to.att|ain slig|
|000046a0| 68 74 6c 79 20 68 69 67 | 68 65 72 20 73 70 65 65 |htly hig|her spee|
|000046b0| 64 20 61 74 20 6c 6f 77 | 65 72 20 61 63 63 75 72 |d at low|er accur|
|000046c0| 61 63 79 2e 0d 0d 43 41 | 55 54 49 4f 4e 3a 20 54 |acy...CA|UTION: T|
|000046d0| 68 69 73 20 72 6f 75 74 | 69 6e 65 20 69 73 20 61 |his rout|ine is a|
|000046e0| 20 73 74 61 63 6b 20 68 | 6f 67 2e 20 45 61 63 68 | stack h|og. Each|
|000046f0| 20 63 61 6c 6c 20 75 73 | 65 73 20 75 70 20 61 62 | call us|es up ab|
|00004700| 6f 75 74 20 36 34 20 62 | 79 74 65 73 20 6f 6e 20 |out 64 b|ytes on |
|00004710| 74 68 65 0d 73 74 61 63 | 6b 2c 20 61 6e 64 20 69 |the.stac|k, and i|
|00004720| 74 20 63 61 6c 6c 73 20 | 69 74 73 65 6c 66 20 72 |t calls |itself r|
|00004730| 65 63 75 72 73 69 76 65 | 6c 79 2c 20 75 70 20 74 |ecursive|ly, up t|
|00004740| 6f 20 6c 6f 67 32 28 32 | 35 36 2f 4c 49 4e 45 41 |o log2(2|56/LINEA|
|00004750| 52 5f 56 5f 44 4f 4d 41 | 49 4e 29 20 74 69 6d 65 |R_V_DOMA|IN) time|
|00004760| 73 2e 0d 44 6f 20 4e 4f | 54 20 63 68 61 6e 67 65 |s..Do NO|T change|
|00004770| 20 61 6e 79 20 6f 66 20 | 74 68 65 20 64 65 63 6c | any of |the decl|
|00004780| 61 72 61 74 69 6f 6e 73 | 20 6f 66 20 74 68 65 20 |arations| of the |
|00004790| 22 6e 65 77 22 20 76 61 | 72 69 61 62 6c 65 73 20 |"new" va|riables |
|000047a0| 75 73 65 64 20 69 6e 20 | 74 68 65 20 66 69 72 73 |used in |the firs|
|000047b0| 74 0d 69 66 7b 7d 20 74 | 6f 20 22 73 74 61 74 69 |t.if{} t|o "stati|
|000047c0| 63 22 2c 20 61 73 20 74 | 68 61 74 20 77 6f 75 6c |c", as t|hat woul|
|000047d0| 64 20 63 61 75 73 65 20 | 74 68 65 20 72 65 63 75 |d cause |the recu|
|000047e0| 72 73 69 6f 6e 20 74 6f | 20 66 61 69 6c 2e 0d 2a |rsion to| fail..*|
|000047f0| 2f 0d 7b 0d 09 73 74 61 | 74 69 63 20 69 6e 74 20 |/.{..sta|tic int |
|00004800| 64 6f 4c 61 73 74 3d 31 | 3b 0d 09 69 6e 74 20 73 |doLast=1|;..int s|
|00004810| 61 76 65 44 6f 4c 61 73 | 74 3b 0d 09 69 6e 74 20 |aveDoLas|t;..int |
|00004820| 6e 65 77 4f 6e 65 3b 0d | 09 46 49 58 45 44 20 5f |newOne;.|.FIXED _|
|00004830| 6e 65 77 4c 2c 5f 6e 65 | 77 56 3b 0d 09 72 65 67 |newL,_ne|wV;..reg|
|00004840| 69 73 74 65 72 20 4c 75 | 6d 69 6e 61 6e 63 65 52 |ister Lu|minanceR|
|00004850| 65 63 6f 72 64 20 2a 4c | 50 3d 4c 50 74 72 3b 0d |ecord *L|P=LPtr;.|
|00004860| 09 72 65 67 69 73 74 65 | 72 20 69 6e 74 20 69 2c |.registe|r int i,|
|00004870| 56 69 3b 0d 09 72 65 67 | 69 73 74 65 72 20 46 49 |Vi;..reg|ister FI|
|00004880| 58 45 44 20 5f 56 54 6f | 47 6f 2c 5f 67 3b 0d 09 |XED _VTo|Go,_g;..|
|00004890| 73 74 61 74 69 63 20 52 | 47 42 43 6f 6c 6f 72 20 |static R|GBColor |
|000048a0| 2a 52 47 42 50 74 72 3b | 09 2f 2a 20 73 74 61 74 |*RGBPtr;|./* stat|
|000048b0| 69 63 20 69 6e 20 6f 72 | 64 65 72 20 74 6f 20 6d |ic in or|der to m|
|000048c0| 69 6e 69 6d 69 7a 65 20 | 73 74 61 63 6b 20 75 73 |inimize |stack us|
|000048d0| 61 67 65 20 2a 2f 0d 09 | 73 74 61 74 69 63 20 69 |age */..|static i|
|000048e0| 6e 74 20 74 68 65 45 6e | 74 72 79 3b 09 09 2f 2a |nt theEn|try;../*|
|000048f0| 20 73 74 61 74 69 63 20 | 69 6e 20 6f 72 64 65 72 | static |in order|
|00004900| 20 74 6f 20 6d 69 6e 69 | 6d 69 7a 65 20 73 74 61 | to mini|mize sta|
|00004910| 63 6b 20 75 73 61 67 65 | 20 2a 2f 0d 09 73 74 61 |ck usage| */..sta|
|00004920| 74 69 63 20 46 49 58 45 | 44 20 5f 56 2c 5f 64 56 |tic FIXE|D _V,_dV|
|00004930| 3b 09 09 2f 2a 20 73 74 | 61 74 69 63 20 69 6e 20 |;../* st|atic in |
|00004940| 6f 72 64 65 72 20 74 6f | 20 6d 69 6e 69 6d 69 7a |order to| minimiz|
|00004950| 65 20 73 74 61 63 6b 20 | 75 73 61 67 65 20 2a 2f |e stack |usage */|
|00004960| 0d 09 72 65 67 69 73 74 | 65 72 20 73 68 6f 72 74 |..regist|er short|
|00004970| 20 6c 65 66 74 53 68 69 | 66 74 3b 0d 09 0d 09 69 | leftShi|ft;....i|
|00004980| 66 28 6c 61 73 74 2d 66 | 69 72 73 74 3e 31 20 29 |f(last-f|irst>1 )|
|00004990| 7b 0d 09 09 5f 64 56 3d | 5f 6c 61 73 74 56 2d 5f |{..._dV=|_lastV-_|
|000049a0| 66 69 72 73 74 56 3b 0d | 09 09 69 66 28 5f 64 56 |firstV;.|..if(_dV|
|000049b0| 3e 4c 6f 6e 67 54 6f 46 | 69 78 28 4c 49 4e 45 41 |>LongToF|ix(LINEA|
|000049c0| 52 5f 56 5f 44 4f 4d 41 | 49 4e 29 20 7c 7c 20 5f |R_V_DOMA|IN) || _|
|000049d0| 64 56 3c 4c 6f 6e 67 54 | 6f 46 69 78 28 2d 4c 49 |dV<LongT|oFix(-LI|
|000049e0| 4e 45 41 52 5f 56 5f 44 | 4f 4d 41 49 4e 29 29 7b |NEAR_V_D|OMAIN)){|
|000049f0| 0d 09 09 09 6e 65 77 4f | 6e 65 3d 28 66 69 72 73 |....newO|ne=(firs|
|00004a00| 74 2b 6c 61 73 74 29 3e | 3e 31 3b 0d 09 09 09 23 |t+last)>|>1;....#|
|00004a10| 69 66 20 46 41 53 54 5f | 4c 55 4d 49 4e 41 4e 43 |if FAST_|LUMINANC|
|00004a20| 45 0d 09 09 09 09 5f 6e | 65 77 4c 3d 5f 66 69 72 |E....._n|ewL=_fir|
|00004a30| 73 74 4c 2b 28 28 6e 65 | 77 4f 6e 65 2d 66 69 72 |stL+((ne|wOne-fir|
|00004a40| 73 74 29 2a 5f 64 4c 36 | 34 3e 3e 36 29 3b 0d 09 |st)*_dL6|4>>6);..|
|00004a50| 09 09 23 65 6c 73 65 0d | 09 09 09 09 5f 6e 65 77 |..#else.|...._new|
|00004a60| 4c 3d 5f 66 69 72 73 74 | 4c 2b 28 6e 65 77 4f 6e |L=_first|L+(newOn|
|00004a70| 65 2d 66 69 72 73 74 29 | 2a 5f 64 4c 36 34 3b 0d |e-first)|*_dL64;.|
|00004a80| 09 09 09 23 65 6e 64 69 | 66 0d 09 09 09 5f 6e 65 |...#endi|f...._ne|
|00004a90| 77 56 3d 5f 4c 54 6f 56 | 28 4c 50 2c 5f 6e 65 77 |wV=_LToV|(LP,_new|
|00004aa0| 4c 20 2b 20 4c 50 2d 3e | 5f 4c 4f 66 66 73 65 74 |L + LP->|_LOffset|
|00004ab0| 29 3b 0d 09 09 09 73 61 | 76 65 44 6f 4c 61 73 74 |);....sa|veDoLast|
|00004ac0| 3d 64 6f 4c 61 73 74 3b | 0d 09 09 09 64 6f 4c 61 |=doLast;|....doLa|
|00004ad0| 73 74 3d 30 3b 0d 09 09 | 09 5f 53 65 74 4c 75 6d |st=0;...|._SetLum|
|00004ae0| 69 6e 61 6e 63 65 73 28 | 4c 50 2c 66 69 72 73 74 |inances(|LP,first|
|00004af0| 2c 6e 65 77 4f 6e 65 2c | 5f 66 69 72 73 74 4c 2c |,newOne,|_firstL,|
|00004b00| 5f 64 4c 36 34 2c 5f 66 | 69 72 73 74 56 2c 5f 6e |_dL64,_f|irstV,_n|
|00004b10| 65 77 56 29 3b 0d 09 09 | 09 64 6f 4c 61 73 74 3d |ewV);...|.doLast=|
|00004b20| 73 61 76 65 44 6f 4c 61 | 73 74 3b 0d 09 09 09 5f |saveDoLa|st;...._|
|00004b30| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 73 28 4c 50 |SetLumin|ances(LP|
|00004b40| 2c 6e 65 77 4f 6e 65 2c | 6c 61 73 74 2c 5f 6e 65 |,newOne,|last,_ne|
|00004b50| 77 4c 2c 5f 64 4c 36 34 | 2c 5f 6e 65 77 56 2c 5f |wL,_dL64|,_newV,_|
|00004b60| 6c 61 73 74 56 29 3b 0d | 09 09 09 72 65 74 75 72 |lastV);.|...retur|
|00004b70| 6e 3b 0d 09 09 7d 0d 09 | 7d 0d 09 69 66 28 6c 61 |n;...}..|}..if(la|
|00004b80| 73 74 21 3d 66 69 72 73 | 74 29 5f 64 56 3d 28 5f |st!=firs|t)_dV=(_|
|00004b90| 6c 61 73 74 56 2d 5f 66 | 69 72 73 74 56 29 2f 28 |lastV-_f|irstV)/(|
|00004ba0| 6c 61 73 74 2d 66 69 72 | 73 74 29 3b 0d 09 65 6c |last-fir|st);..el|
|00004bb0| 73 65 20 5f 64 56 3d 30 | 3b 0d 09 69 66 28 21 64 |se _dV=0|;..if(!d|
|00004bc0| 6f 4c 61 73 74 29 6c 61 | 73 74 2d 2d 3b 0d 09 6c |oLast)la|st--;..l|
|00004bd0| 65 66 74 53 68 69 66 74 | 3d 4c 50 2d 3e 6c 65 66 |eftShift|=LP->lef|
|00004be0| 74 53 68 69 66 74 3b 0d | 09 66 6f 72 28 74 68 65 |tShift;.|.for(the|
|00004bf0| 45 6e 74 72 79 3d 66 69 | 72 73 74 2c 5f 56 3d 5f |Entry=fi|rst,_V=_|
|00004c00| 66 69 72 73 74 56 3b 74 | 68 65 45 6e 74 72 79 3c |firstV;t|heEntry<|
|00004c10| 3d 6c 61 73 74 3b 74 68 | 65 45 6e 74 72 79 2b 2b |=last;th|eEntry++|
|00004c20| 2c 5f 56 2b 3d 5f 64 56 | 29 7b 0d 09 09 2f 2a 2a |,_V+=_dV|){.../**|
|00004c30| 2a 2a 2a 2a 20 54 68 69 | 73 20 73 65 63 74 69 6f |**** Thi|s sectio|
|00004c40| 6e 20 6f 66 20 63 6f 64 | 65 20 69 73 20 63 6f 70 |n of cod|e is cop|
|00004c50| 69 65 64 20 66 72 6f 6d | 20 5f 53 65 74 4c 75 6d |ied from| _SetLum|
|00004c60| 69 6e 61 6e 63 65 28 29 | 20 2a 2a 2a 2a 2f 0d 09 |inance()| ****/..|
|00004c70| 09 52 47 42 50 74 72 20 | 3d 20 26 4c 50 2d 3e 74 |.RGBPtr |= &LP->t|
|00004c80| 61 62 6c 65 5b 74 68 65 | 45 6e 74 72 79 5d 2e 72 |able[the|Entry].r|
|00004c90| 67 62 3b 0d 09 09 2a 52 | 47 42 50 74 72 3d 4c 50 |gb;...*R|GBPtr=LP|
|00004ca0| 2d 3e 72 67 62 3b 09 09 | 09 09 09 09 2f 2a 20 6c |->rgb;..|..../* l|
|00004cb0| 6f 61 64 20 66 6f 72 20 | 66 69 78 65 64 20 44 41 |oad for |fixed DA|
|00004cc0| 43 73 20 2a 2f 0d 09 09 | 5f 56 54 6f 47 6f 3d 5f |Cs */...|_VToGo=_|
|00004cd0| 56 20 2d 20 4c 50 2d 3e | 5f 56 46 69 78 65 64 20 |V - LP->|_VFixed |
|00004ce0| 2b 20 4c 50 2d 3e 5f 56 | 48 61 6c 66 53 74 65 70 |+ LP->_V|HalfStep|
|00004cf0| 3b 0d 09 09 66 6f 72 28 | 69 3d 4c 50 2d 3e 66 69 |;...for(|i=LP->fi|
|00004d00| 78 65 64 3b 69 3c 4c 50 | 2d 3e 64 61 63 73 3b 69 |xed;i<LP|->dacs;i|
|00004d10| 2b 2b 29 20 7b 0d 09 09 | 09 5f 67 3d 4c 50 2d 3e |++) {...|._g=LP->|
|00004d20| 5f 67 61 69 6e 5b 69 5d | 3b 0d 09 09 09 56 69 3d |_gain[i]|;....Vi=|
|00004d30| 5f 56 54 6f 47 6f 2f 5f | 67 3b 09 09 09 09 09 09 |_VToGo/_|g;......|
|00004d40| 2f 2a 20 74 72 75 6e 63 | 61 74 65 20 74 6f 20 69 |/* trunc|ate to i|
|00004d50| 6e 74 65 67 65 72 20 2a | 2f 0d 09 09 09 69 66 28 |nteger *|/....if(|
|00004d60| 56 69 3e 4c 50 2d 3e 56 | 4d 61 78 29 56 69 3d 4c |Vi>LP->V|Max)Vi=L|
|00004d70| 50 2d 3e 56 4d 61 78 3b | 0d 09 09 09 69 66 28 56 |P->VMax;|....if(V|
|00004d80| 69 3c 4c 50 2d 3e 56 4d | 69 6e 29 56 69 3d 4c 50 |i<LP->VM|in)Vi=LP|
|00004d90| 2d 3e 56 4d 69 6e 3b 0d | 09 09 09 5f 56 54 6f 47 |->VMin;.|..._VToG|
|00004da0| 6f 20 2d 3d 20 56 69 2a | 5f 67 3b 0d 09 09 09 28 |o -= Vi*|_g;....(|
|00004db0| 28 73 68 6f 72 74 20 2a | 29 52 47 42 50 74 72 29 |(short *|)RGBPtr)|
|00004dc0| 5b 4c 50 2d 3e 64 61 63 | 5b 69 5d 5d 3d 56 69 3c |[LP->dac|[i]]=Vi<|
|00004dd0| 3c 6c 65 66 74 53 68 69 | 66 74 3b 0d 09 09 7d 0d |<leftShi|ft;...}.|
|00004de0| 09 09 2f 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |../*****|********|
|00004df0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004e00| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004e10| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00004e20| 2a 2a 2f 0d 09 7d 0d 09 | 72 65 74 75 72 6e 3b 0d |**/..}..|return;.|
|00004e30| 7d 0d 0d 76 6f 69 64 20 | 5f 53 65 74 4c 75 6d 69 |}..void |_SetLumi|
|00004e40| 6e 61 6e 63 65 28 4c 75 | 6d 69 6e 61 6e 63 65 52 |nance(Lu|minanceR|
|00004e50| 65 63 6f 72 64 20 2a 4c | 50 74 72 2c 69 6e 74 20 |ecord *L|Ptr,int |
|00004e60| 74 68 65 45 6e 74 72 79 | 2c 46 49 58 45 44 20 5f |theEntry|,FIXED _|
|00004e70| 6c 75 6d 69 6e 61 6e 63 | 65 29 0d 2f 2a 0d 53 65 |luminanc|e)./*.Se|
|00004e80| 74 20 6f 6e 65 20 65 6e | 74 72 79 20 69 6e 20 74 |t one en|try in t|
|00004e90| 68 65 20 43 6f 6c 6f 72 | 53 70 65 63 20 74 61 62 |he Color|Spec tab|
|00004ea0| 6c 65 20 74 6f 20 61 20 | 73 70 65 63 69 66 69 65 |le to a |specifie|
|00004eb0| 64 20 6c 75 6d 69 6e 61 | 6e 63 65 2e 20 54 68 69 |d lumina|nce. Thi|
|00004ec0| 73 20 69 73 20 74 68 65 | 0d 70 72 69 76 61 74 65 |s is the|.private|
|00004ed0| 20 73 75 62 72 6f 75 74 | 69 6e 65 20 74 68 61 74 | subrout|ine that|
|00004ee0| 20 61 63 74 75 61 6c 6c | 79 20 64 6f 65 73 20 61 | actuall|y does a|
|00004ef0| 6c 6c 20 74 68 65 20 77 | 6f 72 6b 20 66 6f 72 20 |ll the w|ork for |
|00004f00| 53 65 74 4c 75 6d 69 6e | 61 6e 63 65 28 29 2e 20 |SetLumin|ance(). |
|00004f10| 54 68 69 73 0d 72 6f 75 | 74 69 6e 65 20 69 73 20 |This.rou|tine is |
|00004f20| 64 65 73 69 67 6e 65 64 | 20 74 6f 20 72 75 6e 20 |designed| to run |
|00004f30| 61 73 20 66 61 73 74 20 | 61 73 20 70 6f 73 73 69 |as fast |as possi|
|00004f40| 62 6c 65 2e 0d 2a 2f 0d | 7b 0d 09 72 65 67 69 73 |ble..*/.|{..regis|
|00004f50| 74 65 72 20 4c 75 6d 69 | 6e 61 6e 63 65 52 65 63 |ter Lumi|nanceRec|
|00004f60| 6f 72 64 20 2a 4c 50 3d | 4c 50 74 72 3b 0d 09 72 |ord *LP=|LPtr;..r|
|00004f70| 65 67 69 73 74 65 72 20 | 69 6e 74 20 69 2c 56 69 |egister |int i,Vi|
|00004f80| 3b 0d 09 72 65 67 69 73 | 74 65 72 20 46 49 58 45 |;..regis|ter FIXE|
|00004f90| 44 20 5f 56 54 6f 47 6f | 2c 5f 67 3b 0d 09 52 47 |D _VToGo|,_g;..RG|
|00004fa0| 42 43 6f 6c 6f 72 20 2a | 52 47 42 50 74 72 3b 0d |BColor *|RGBPtr;.|
|00004fb0| 09 72 65 67 69 73 74 65 | 72 20 73 68 6f 72 74 20 |.registe|r short |
|00004fc0| 6c 65 66 74 53 68 69 66 | 74 3d 4c 50 2d 3e 6c 65 |leftShif|t=LP->le|
|00004fd0| 66 74 53 68 69 66 74 3b | 0d 09 0d 09 52 47 42 50 |ftShift;|....RGBP|
|00004fe0| 74 72 20 3d 20 26 4c 50 | 2d 3e 74 61 62 6c 65 5b |tr = &LP|->table[|
|00004ff0| 74 68 65 45 6e 74 72 79 | 5d 2e 72 67 62 3b 0d 09 |theEntry|].rgb;..|
|00005000| 2a 52 47 42 50 74 72 3d | 4c 50 2d 3e 72 67 62 3b |*RGBPtr=|LP->rgb;|
|00005010| 09 09 09 09 09 09 2f 2a | 20 6c 6f 61 64 20 66 6f |....../*| load fo|
|00005020| 72 20 66 69 78 65 64 20 | 44 41 43 73 20 2a 2f 0d |r fixed |DACs */.|
|00005030| 09 5f 56 54 6f 47 6f 3d | 5f 4c 54 6f 56 28 4c 50 |._VToGo=|_LToV(LP|
|00005040| 2c 5f 6c 75 6d 69 6e 61 | 6e 63 65 20 2b 20 4c 50 |,_lumina|nce + LP|
|00005050| 2d 3e 5f 4c 4f 66 66 73 | 65 74 29 20 2d 20 4c 50 |->_LOffs|et) - LP|
|00005060| 2d 3e 5f 56 46 69 78 65 | 64 20 2b 20 4c 50 2d 3e |->_VFixe|d + LP->|
|00005070| 5f 56 48 61 6c 66 53 74 | 65 70 3b 0d 09 66 6f 72 |_VHalfSt|ep;..for|
|00005080| 28 69 3d 4c 50 2d 3e 66 | 69 78 65 64 3b 69 3c 4c |(i=LP->f|ixed;i<L|
|00005090| 50 2d 3e 64 61 63 73 3b | 69 2b 2b 29 20 7b 0d 09 |P->dacs;|i++) {..|
|000050a0| 09 5f 67 3d 4c 50 2d 3e | 5f 67 61 69 6e 5b 69 5d |._g=LP->|_gain[i]|
|000050b0| 3b 0d 09 09 56 69 3d 5f | 56 54 6f 47 6f 2f 5f 67 |;...Vi=_|VToGo/_g|
|000050c0| 3b 09 09 09 09 09 09 2f | 2a 20 74 72 75 6e 63 61 |;....../|* trunca|
|000050d0| 74 65 20 74 6f 20 69 6e | 74 65 67 65 72 20 2a 2f |te to in|teger */|
|000050e0| 0d 09 09 69 66 28 56 69 | 3e 4c 50 2d 3e 56 4d 61 |...if(Vi|>LP->VMa|
|000050f0| 78 29 56 69 3d 4c 50 2d | 3e 56 4d 61 78 3b 0d 09 |x)Vi=LP-|>VMax;..|
|00005100| 09 69 66 28 56 69 3c 4c | 50 2d 3e 56 4d 69 6e 29 |.if(Vi<L|P->VMin)|
|00005110| 56 69 3d 4c 50 2d 3e 56 | 4d 69 6e 3b 0d 09 09 5f |Vi=LP->V|Min;..._|
|00005120| 56 54 6f 47 6f 20 2d 3d | 20 56 69 2a 5f 67 3b 0d |VToGo -=| Vi*_g;.|
|00005130| 09 09 28 28 73 68 6f 72 | 74 20 2a 29 52 47 42 50 |..((shor|t *)RGBP|
|00005140| 74 72 29 5b 4c 50 2d 3e | 64 61 63 5b 69 5d 5d 3d |tr)[LP->|dac[i]]=|
|00005150| 56 69 3c 3c 6c 65 66 74 | 53 68 69 66 74 3b 0d 09 |Vi<<left|Shift;..|
|00005160| 7d 0d 7d 0d 0d 76 6f 69 | 64 20 49 6e 63 72 65 6d |}.}..voi|d Increm|
|00005170| 65 6e 74 4c 75 6d 69 6e | 61 6e 63 65 28 47 44 48 |entLumin|ance(GDH|
|00005180| 61 6e 64 6c 65 20 64 65 | 76 69 63 65 2c 72 65 67 |andle de|vice,reg|
|00005190| 69 73 74 65 72 20 4c 75 | 6d 69 6e 61 6e 63 65 52 |ister Lu|minanceR|
|000051a0| 65 63 6f 72 64 20 2a 4c | 50 2c 69 6e 74 20 74 68 |ecord *L|P,int th|
|000051b0| 65 45 6e 74 72 79 29 0d | 2f 2a 0d 4d 61 6b 65 20 |eEntry).|/*.Make |
|000051c0| 73 6d 61 6c 6c 65 73 74 | 20 70 6f 73 73 69 62 6c |smallest| possibl|
|000051d0| 65 20 69 6e 63 72 65 61 | 73 65 20 6f 66 20 74 68 |e increa|se of th|
|000051e0| 65 20 6c 75 6d 69 6e 61 | 6e 63 65 20 6f 66 20 6f |e lumina|nce of o|
|000051f0| 6e 65 20 65 6e 74 72 79 | 20 69 6e 20 74 68 65 20 |ne entry| in the |
|00005200| 43 6f 6c 6f 72 53 70 65 | 63 0d 74 61 62 6c 65 2e |ColorSpe|c.table.|
|00005210| 20 49 66 20 6e 65 63 65 | 73 73 61 72 79 2c 20 62 | If nece|ssary, b|
|00005220| 75 6d 70 20 75 70 20 74 | 68 65 20 75 70 70 65 72 |ump up t|he upper|
|00005230| 20 6c 75 6d 69 6e 61 6e | 63 65 20 62 6f 75 6e 64 | luminan|ce bound|
|00005240| 20 74 6f 20 69 6e 63 6c | 75 64 65 20 74 68 65 20 | to incl|ude the |
|00005250| 69 6e 63 72 65 6d 65 6e | 74 65 64 20 6c 75 6d 69 |incremen|ted lumi|
|00005260| 6e 61 6e 63 65 2e 0d 2a | 2f 0d 7b 0d 09 64 6f 75 |nance..*|/.{..dou|
|00005270| 62 6c 65 20 56 2c 4c 2c | 68 69 67 68 4c 3b 0d 09 |ble V,L,|highL;..|
|00005280| 0d 09 56 3d 47 65 74 56 | 28 64 65 76 69 63 65 2c |..V=GetV|(device,|
|00005290| 4c 50 2c 74 68 65 45 6e | 74 72 79 29 3b 0d 09 56 |LP,theEn|try);..V|
|000052a0| 2b 3d 4c 50 2d 3e 56 48 | 61 6c 66 53 74 65 70 3b |+=LP->VH|alfStep;|
|000052b0| 0d 09 56 2b 3d 4c 50 2d | 3e 56 48 61 6c 66 53 74 |..V+=LP-|>VHalfSt|
|000052c0| 65 70 3b 0d 09 4c 3d 56 | 54 6f 4c 28 4c 50 2c 56 |ep;..L=V|ToL(LP,V|
|000052d0| 29 3b 0d 09 69 66 28 4c | 3e 4c 50 2d 3e 68 69 67 |);..if(L|>LP->hig|
|000052e0| 68 4c 75 6d 69 6e 61 6e | 63 65 29 68 69 67 68 4c |hLuminan|ce)highL|
|000052f0| 3d 4c 3b 0d 09 65 6c 73 | 65 20 68 69 67 68 4c 3d |=L;..els|e highL=|
|00005300| 4c 50 2d 3e 68 69 67 68 | 4c 75 6d 69 6e 61 6e 63 |LP->high|Luminanc|
|00005310| 65 3b 0d 09 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 |e;..SetL|uminance|
|00005320| 28 64 65 76 69 63 65 2c | 4c 50 2c 74 68 65 45 6e |(device,|LP,theEn|
|00005330| 74 72 79 2c 4c 2c 4c 50 | 2d 3e 6c 6f 77 4c 75 6d |try,L,LP|->lowLum|
|00005340| 69 6e 61 6e 63 65 2c 68 | 69 67 68 4c 29 3b 0d 7d |inance,h|ighL);.}|
|00005350| 0d 0d 46 49 58 45 44 20 | 5f 54 6f 6c 65 72 61 6e |..FIXED |_Toleran|
|00005360| 63 65 28 4c 75 6d 69 6e | 61 6e 63 65 52 65 63 6f |ce(Lumin|anceReco|
|00005370| 72 64 20 2a 4c 50 74 72 | 2c 46 49 58 45 44 20 5f |rd *LPtr|,FIXED _|
|00005380| 6c 75 6d 69 6e 61 6e 63 | 65 29 0d 7b 0d 09 72 65 |luminanc|e).{..re|
|00005390| 67 69 73 74 65 72 20 4c | 75 6d 69 6e 61 6e 63 65 |gister L|uminance|
|000053a0| 52 65 63 6f 72 64 20 2a | 4c 50 3d 4c 50 74 72 3b |Record *|LP=LPtr;|
|000053b0| 0d 09 72 65 67 69 73 74 | 65 72 20 46 49 58 45 44 |..regist|er FIXED|
|000053c0| 20 5f 74 6f 6c 65 72 61 | 6e 63 65 2c 5f 74 3b 0d | _tolera|nce,_t;.|
|000053d0| 09 0d 09 2f 2a 20 71 75 | 69 63 6b 20 61 6e 64 20 |.../* qu|ick and |
|000053e0| 64 69 72 74 79 20 65 73 | 74 69 6d 61 74 65 20 6f |dirty es|timate o|
|000053f0| 66 20 74 6f 6c 65 72 61 | 6e 63 65 20 2a 2f 0d 09 |f tolera|nce */..|
|00005400| 69 66 28 4c 50 2d 3e 4c | 2e 65 78 69 73 74 73 3d |if(LP->L|.exists=|
|00005410| 3d 6c 75 6d 69 6e 61 6e | 63 65 53 65 74 29 7b 0d |=luminan|ceSet){.|
|00005420| 09 09 5f 74 6f 6c 65 72 | 61 6e 63 65 3d 4c 50 2d |.._toler|ance=LP-|
|00005430| 3e 4c 2e 5f 4c 75 5b 30 | 5d 20 2d 20 5f 6c 75 6d |>L._Lu[0|] - _lum|
|00005440| 69 6e 61 6e 63 65 3b 0d | 09 09 5f 74 3d 5f 6c 75 |inance;.|.._t=_lu|
|00005450| 6d 69 6e 61 6e 63 65 20 | 2d 20 4c 50 2d 3e 4c 2e |minance |- LP->L.|
|00005460| 5f 4c 75 5b 4c 55 4d 49 | 4e 41 4e 43 45 53 5f 49 |_Lu[LUMI|NANCES_I|
|00005470| 4e 5f 54 41 42 4c 45 2d | 31 5d 3b 0d 09 09 69 66 |N_TABLE-|1];...if|
|00005480| 28 5f 74 6f 6c 65 72 61 | 6e 63 65 3c 5f 74 29 5f |(_tolera|nce<_t)_|
|00005490| 74 6f 6c 65 72 61 6e 63 | 65 3d 5f 74 3b 0d 09 09 |toleranc|e=_t;...|
|000054a0| 69 66 28 5f 74 6f 6c 65 | 72 61 6e 63 65 3c 30 29 |if(_tole|rance<0)|
|000054b0| 5f 74 6f 6c 65 72 61 6e | 63 65 3d 30 3b 0d 09 09 |_toleran|ce=0;...|
|000054c0| 5f 74 6f 6c 65 72 61 6e | 63 65 2b 3d 4c 50 2d 3e |_toleran|ce+=LP->|
|000054d0| 5f 74 6f 6c 65 72 61 6e | 63 65 3b 0d 09 7d 0d 09 |_toleran|ce;..}..|
|000054e0| 65 6c 73 65 20 5f 74 6f | 6c 65 72 61 6e 63 65 3d |else _to|lerance=|
|000054f0| 4c 50 2d 3e 5f 74 6f 6c | 65 72 61 6e 63 65 3b 0d |LP->_tol|erance;.|
|00005500| 09 72 65 74 75 72 6e 20 | 5f 74 6f 6c 65 72 61 6e |.return |_toleran|
|00005510| 63 65 3b 0d 7d 0d 0d 64 | 6f 75 62 6c 65 20 47 65 |ce;.}..d|ouble Ge|
|00005520| 74 4c 75 6d 69 6e 61 6e | 63 65 28 47 44 48 61 6e |tLuminan|ce(GDHan|
|00005530| 64 6c 65 20 64 65 76 69 | 63 65 2c 4c 75 6d 69 6e |dle devi|ce,Lumin|
|00005540| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 2c 69 |anceReco|rd *LP,i|
|00005550| 6e 74 20 74 68 65 45 6e | 74 72 79 29 0d 2f 2a 0d |nt theEn|try)./*.|
|00005560| 49 66 20 64 65 76 69 63 | 65 20 69 73 20 6e 6f 74 |If devic|e is not|
|00005570| 20 4e 55 4c 4c 20 74 68 | 65 6e 20 65 78 61 6d 69 | NULL th|en exami|
|00005580| 6e 65 73 20 6f 6e 65 20 | 65 6e 74 72 79 20 69 6e |nes one |entry in|
|00005590| 20 74 68 65 20 61 63 74 | 75 61 6c 20 63 6c 75 74 | the act|ual clut|
|000055a0| 2c 20 6f 74 68 65 72 77 | 69 73 65 0d 65 78 61 6d |, otherw|ise.exam|
|000055b0| 69 6e 65 73 20 74 68 65 | 20 43 6f 6c 6f 72 53 70 |ines the| ColorSp|
|000055c0| 65 63 20 74 61 62 6c 65 | 20 63 6f 6e 74 61 69 6e |ec table| contain|
|000055d0| 65 64 20 69 6e 20 2a 4c | 50 2c 20 61 6e 64 20 69 |ed in *L|P, and i|
|000055e0| 6e 20 65 69 74 68 65 72 | 20 63 61 73 65 20 72 65 |n either| case re|
|000055f0| 74 75 72 6e 73 20 74 68 | 65 0d 6c 75 6d 69 6e 61 |turns th|e.lumina|
|00005600| 6e 63 65 20 74 68 61 74 | 20 77 69 6c 6c 20 62 65 |nce that| will be|
|00005610| 20 70 72 6f 64 75 63 65 | 64 2e 20 53 75 70 70 6c | produce|d. Suppl|
|00005620| 79 69 6e 67 20 61 6e 20 | 69 6c 6c 65 67 61 6c 20 |ying an |illegal |
|00005630| 65 6e 74 72 79 20 76 61 | 6c 75 65 20 72 65 73 75 |entry va|lue resu|
|00005640| 6c 74 73 20 69 6e 20 61 | 0d 72 65 74 75 72 6e 65 |lts in a|.returne|
|00005650| 64 20 76 61 6c 75 65 20 | 6f 66 20 2d 49 4e 46 2e |d value |of -INF.|
|00005660| 0d 2a 2f 0d 7b 0d 09 72 | 65 74 75 72 6e 20 56 54 |.*/.{..r|eturn VT|
|00005670| 6f 4c 28 4c 50 2c 47 65 | 74 56 28 64 65 76 69 63 |oL(LP,Ge|tV(devic|
|00005680| 65 2c 4c 50 2c 74 68 65 | 45 6e 74 72 79 29 29 3b |e,LP,the|Entry));|
|00005690| 0d 7d 0d 0d 64 6f 75 62 | 6c 65 20 47 65 74 56 28 |.}..doub|le GetV(|
|000056a0| 47 44 48 61 6e 64 6c 65 | 20 64 65 76 69 63 65 2c |GDHandle| device,|
|000056b0| 4c 75 6d 69 6e 61 6e 63 | 65 52 65 63 6f 72 64 20 |Luminanc|eRecord |
|000056c0| 2a 4c 50 2c 69 6e 74 20 | 74 68 65 45 6e 74 72 79 |*LP,int |theEntry|
|000056d0| 29 0d 2f 2a 0d 49 66 20 | 64 65 76 69 63 65 20 69 |)./*.If |device i|
|000056e0| 73 20 6e 6f 74 20 4e 55 | 4c 4c 20 28 61 6e 64 20 |s not NU|LL (and |
|000056f0| 68 61 73 20 61 20 64 72 | 69 76 65 72 29 20 74 68 |has a dr|iver) th|
|00005700| 65 6e 20 65 78 61 6d 69 | 6e 65 73 20 6f 6e 65 20 |en exami|nes one |
|00005710| 65 6e 74 72 79 20 69 6e | 20 74 68 65 20 61 63 74 |entry in| the act|
|00005720| 75 61 6c 20 63 6c 75 74 | 2c 20 6f 74 68 65 72 77 |ual clut|, otherw|
|00005730| 69 73 65 0d 65 78 61 6d | 69 6e 65 73 20 74 68 65 |ise.exam|ines the|
|00005740| 20 43 6f 6c 6f 72 53 70 | 65 63 20 74 61 62 6c 65 | ColorSp|ec table|
|00005750| 20 63 6f 6e 74 61 69 6e | 65 64 20 69 6e 20 2a 4c | contain|ed in *L|
|00005760| 50 2c 20 61 6e 64 20 69 | 6e 20 65 69 74 68 65 72 |P, and i|n either|
|00005770| 20 63 61 73 65 20 72 65 | 74 75 72 6e 73 20 74 68 | case re|turns th|
|00005780| 65 20 56 0d 74 68 61 74 | 20 77 69 6c 6c 20 62 65 |e V.that| will be|
|00005790| 20 70 72 6f 64 75 63 65 | 64 2e 20 53 75 70 70 6c | produce|d. Suppl|
|000057a0| 79 69 6e 67 20 61 6e 20 | 69 6c 6c 65 67 61 6c 20 |ying an |illegal |
|000057b0| 65 6e 74 72 79 20 76 61 | 6c 75 65 20 72 65 73 75 |entry va|lue resu|
|000057c0| 6c 74 73 20 69 6e 20 61 | 20 72 65 74 75 72 6e 65 |lts in a| returne|
|000057d0| 64 0d 76 61 6c 75 65 20 | 6f 66 20 2d 49 4e 46 2e |d.value |of -INF.|
|000057e0| 0d 2a 2f 0d 7b 0d 09 52 | 47 42 43 6f 6c 6f 72 20 |.*/.{..R|GBColor |
|000057f0| 2a 6d 79 52 47 42 50 74 | 72 3d 4e 55 4c 4c 3b 0d |*myRGBPt|r=NULL;.|
|00005800| 09 43 6f 6c 6f 72 53 70 | 65 63 20 6d 79 43 53 70 |.ColorSp|ec myCSp|
|00005810| 65 63 3b 0d 09 64 6f 75 | 62 6c 65 20 56 3b 0d 09 |ec;..dou|ble V;..|
|00005820| 69 6e 74 20 65 72 72 6f | 72 3b 0d 09 0d 09 69 66 |int erro|r;....if|
|00005830| 28 64 65 76 69 63 65 20 | 21 3d 20 4e 55 4c 4c 20 |(device |!= NULL |
|00005840| 26 26 20 28 2a 64 65 76 | 69 63 65 29 2d 3e 67 64 |&& (*dev|ice)->gd|
|00005850| 52 65 66 4e 75 6d 21 3d | 30 29 20 7b 0d 09 09 69 |RefNum!=|0) {...i|
|00005860| 66 28 74 68 65 45 6e 74 | 72 79 3c 30 20 7c 7c 20 |f(theEnt|ry<0 || |
|00005870| 74 68 65 45 6e 74 72 79 | 3e 3d 47 44 43 4c 55 54 |theEntry|>=GDCLUT|
|00005880| 53 49 5a 45 28 64 65 76 | 69 63 65 29 29 7b 0d 09 |SIZE(dev|ice)){..|
|00005890| 09 09 50 72 69 6e 74 66 | 45 78 69 74 28 22 47 65 |..Printf|Exit("Ge|
|000058a0| 74 4c 75 6d 69 6e 61 6e | 63 65 3a 20 69 6c 6c 65 |tLuminan|ce: ille|
|000058b0| 67 61 6c 20 65 6e 74 72 | 79 20 25 64 5c 6e 22 2c |gal entr|y %d\n",|
|000058c0| 74 68 65 45 6e 74 72 79 | 29 3b 0d 09 09 7d 0d 09 |theEntry|);...}..|
|000058d0| 09 65 72 72 6f 72 3d 47 | 44 47 65 74 45 6e 74 72 |.error=G|DGetEntr|
|000058e0| 69 65 73 28 64 65 76 69 | 63 65 2c 74 68 65 45 6e |ies(devi|ce,theEn|
|000058f0| 74 72 79 2c 30 2c 26 6d | 79 43 53 70 65 63 29 3b |try,0,&m|yCSpec);|
|00005900| 0d 09 09 69 66 28 65 72 | 72 6f 72 29 7b 0d 09 09 |...if(er|ror){...|
|00005910| 09 50 72 69 6e 74 66 45 | 78 69 74 28 22 47 65 74 |.PrintfE|xit("Get|
|00005920| 4c 75 6d 69 6e 61 6e 63 | 65 3a 20 47 44 47 65 74 |Luminanc|e: GDGet|
|00005930| 45 6e 74 72 69 65 73 20 | 65 72 72 6f 72 20 25 64 |Entries |error %d|
|00005940| 5c 30 30 37 22 2c 65 72 | 72 6f 72 29 3b 0d 09 09 |\007",er|ror);...|
|00005950| 7d 0d 09 09 6d 79 52 47 | 42 50 74 72 3d 26 6d 79 |}...myRG|BPtr=&my|
|00005960| 43 53 70 65 63 2e 72 67 | 62 3b 0d 09 7d 65 6c 73 |CSpec.rg|b;..}els|
|00005970| 65 7b 0d 09 09 69 66 28 | 4c 50 21 3d 4e 55 4c 4c |e{...if(|LP!=NULL|
|00005980| 20 26 26 20 74 68 65 45 | 6e 74 72 79 3e 3d 30 20 | && theE|ntry>=0 |
|00005990| 26 26 20 74 68 65 45 6e | 74 72 79 3c 43 4f 4c 4f |&& theEn|try<COLO|
|000059a0| 52 53 29 20 0d 09 09 09 | 6d 79 52 47 42 50 74 72 |RS) ....|myRGBPtr|
|000059b0| 3d 26 4c 50 2d 3e 74 61 | 62 6c 65 5b 74 68 65 45 |=&LP->ta|ble[theE|
|000059c0| 6e 74 72 79 5d 2e 72 67 | 62 3b 0d 09 7d 0d 09 69 |ntry].rg|b;..}..i|
|000059d0| 66 28 6d 79 52 47 42 50 | 74 72 20 3d 3d 20 4e 55 |f(myRGBP|tr == NU|
|000059e0| 4c 4c 29 20 72 65 74 75 | 72 6e 20 2d 49 4e 46 3b |LL) retu|rn -INF;|
|000059f0| 0d 09 56 20 3d 20 4c 50 | 2d 3e 72 2a 28 6d 79 52 |..V = LP|->r*(myR|
|00005a00| 47 42 50 74 72 2d 3e 72 | 65 64 3e 3e 38 29 3b 0d |GBPtr->r|ed>>8);.|
|00005a10| 09 56 20 2b 3d 20 4c 50 | 2d 3e 67 2a 28 6d 79 52 |.V += LP|->g*(myR|
|00005a20| 47 42 50 74 72 2d 3e 67 | 72 65 65 6e 3e 3e 38 29 |GBPtr->g|reen>>8)|
|00005a30| 3b 0d 09 56 20 2b 3d 20 | 4c 50 2d 3e 62 2a 28 6d |;..V += |LP->b*(m|
|00005a40| 79 52 47 42 50 74 72 2d | 3e 62 6c 75 65 3e 3e 38 |yRGBPtr-|>blue>>8|
|00005a50| 29 3b 0d 09 72 65 74 75 | 72 6e 20 56 3b 0d 7d 0d |);..retu|rn V;.}.|
|00005a60| 0d 76 6f 69 64 20 4c 6f | 61 64 4c 75 6d 69 6e 61 |.void Lo|adLumina|
|00005a70| 6e 63 65 73 28 47 44 48 | 61 6e 64 6c 65 20 64 65 |nces(GDH|andle de|
|00005a80| 76 69 63 65 2c 20 4c 75 | 6d 69 6e 61 6e 63 65 52 |vice, Lu|minanceR|
|00005a90| 65 63 6f 72 64 20 2a 4c | 50 2c 0d 09 69 6e 74 20 |ecord *L|P,..int |
|00005aa0| 66 69 72 73 74 45 6e 74 | 72 79 2c 20 69 6e 74 20 |firstEnt|ry, int |
|00005ab0| 6c 61 73 74 45 6e 74 72 | 79 29 0d 2f 2a 0d 54 68 |lastEntr|y)./*.Th|
|00005ac0| 69 73 20 6a 75 73 74 20 | 63 61 6c 6c 73 20 47 44 |is just |calls GD|
|00005ad0| 53 65 74 45 6e 74 72 69 | 65 73 28 29 20 6f 72 20 |SetEntri|es() or |
|00005ae0| 47 44 44 69 72 65 63 74 | 53 65 74 45 6e 74 72 69 |GDDirect|SetEntri|
|00005af0| 65 73 28 29 20 74 6f 20 | 6c 6f 61 64 20 79 6f 75 |es() to |load you|
|00005b00| 72 20 43 6f 6c 6f 72 53 | 70 65 63 0d 74 61 62 6c |r ColorS|pec.tabl|
|00005b10| 65 20 69 6e 74 6f 20 74 | 68 65 20 63 6c 75 74 20 |e into t|he clut |
|00005b20| 6f 66 20 79 6f 75 72 20 | 73 63 72 65 65 6e 20 64 |of your |screen d|
|00005b30| 65 76 69 63 65 2e 20 49 | 74 20 69 73 20 68 65 72 |evice. I|t is her|
|00005b40| 65 20 73 69 6d 70 6c 79 | 20 74 6f 20 70 72 6f 76 |e simply| to prov|
|00005b50| 69 64 65 20 61 0d 63 6f | 73 6d 65 74 69 63 20 6d |ide a.co|smetic m|
|00005b60| 61 74 63 68 20 74 6f 20 | 74 68 65 20 63 61 6c 6c |atch to |the call|
|00005b70| 20 74 6f 20 53 65 74 4c | 75 6d 69 6e 61 6e 63 65 | to SetL|uminance|
|00005b80| 73 28 29 2c 20 66 6f 72 | 20 77 68 69 63 68 20 6c |s(), for| which l|
|00005b90| 6f 61 64 69 6e 67 20 74 | 68 65 20 63 6c 75 74 20 |oading t|he clut |
|00005ba0| 69 73 0d 6f 70 74 69 6f | 6e 61 6c 2e 20 4e 6f 74 |is.optio|nal. Not|
|00005bb0| 65 3a 20 69 66 20 79 6f | 75 20 70 72 65 66 65 72 |e: if yo|u prefer|
|00005bc0| 2c 20 69 6e 73 74 65 61 | 64 20 6f 66 20 4c 50 20 |, instea|d of LP |
|00005bd0| 79 6f 75 20 6d 61 79 20 | 73 65 6e 64 20 6a 75 73 |you may |send jus|
|00005be0| 74 20 74 68 65 20 61 64 | 64 72 65 73 73 20 6f 66 |t the ad|dress of|
|00005bf0| 20 61 0d 43 6f 6c 6f 72 | 53 70 65 63 20 74 61 62 | a.Color|Spec tab|
|00005c00| 6c 65 2c 20 63 61 73 74 | 20 74 6f 20 28 4c 75 6d |le, cast| to (Lum|
|00005c10| 69 6e 61 6e 63 65 52 65 | 63 6f 72 64 20 2a 29 2c |inanceRe|cord *),|
|00005c20| 20 73 69 6e 63 65 20 61 | 20 4c 75 6d 69 6e 61 6e | since a| Luminan|
|00005c30| 63 65 52 65 63 6f 72 64 | 20 62 65 67 69 6e 73 0d |ceRecord| begins.|
|00005c40| 77 69 74 68 20 61 20 43 | 6f 6c 6f 72 53 70 65 63 |with a C|olorSpec|
|00005c50| 20 74 61 62 6c 65 2e 0d | 2a 2f 0d 7b 0d 09 69 6e | table..|*/.{..in|
|00005c60| 74 20 65 72 72 6f 72 3b | 0d 09 73 68 6f 72 74 20 |t error;|..short |
|00005c70| 69 73 47 72 61 79 2c 69 | 3b 0d 09 52 47 42 43 6f |isGray,i|;..RGBCo|
|00005c80| 6c 6f 72 20 2a 52 47 42 | 50 74 72 3b 0d 09 43 6f |lor *RGB|Ptr;..Co|
|00005c90| 6c 6f 72 53 70 65 63 20 | 74 61 62 6c 65 5b 32 35 |lorSpec |table[25|
|00005ca0| 36 5d 2c 2a 74 61 62 6c | 65 50 74 72 3b 0d 0d 09 |6],*tabl|ePtr;...|
|00005cb0| 69 66 28 64 65 76 69 63 | 65 3d 3d 4e 55 4c 4c 20 |if(devic|e==NULL |
|00005cc0| 7c 7c 20 28 2a 64 65 76 | 69 63 65 29 2d 3e 67 64 ||| (*dev|ice)->gd|
|00005cd0| 52 65 66 4e 75 6d 3d 3d | 30 29 72 65 74 75 72 6e |RefNum==|0)return|
|00005ce0| 3b 09 2f 2f 20 6e 6f 20 | 64 65 76 69 63 65 2c 20 |;.// no |device, |
|00005cf0| 6f 72 20 6e 6f 20 64 65 | 76 69 63 65 20 64 72 69 |or no de|vice dri|
|00005d00| 76 65 72 0d 09 69 73 47 | 72 61 79 3d 21 54 65 73 |ver..isG|ray=!Tes|
|00005d10| 74 44 65 76 69 63 65 41 | 74 74 72 69 62 75 74 65 |tDeviceA|ttribute|
|00005d20| 28 64 65 76 69 63 65 2c | 67 64 44 65 76 54 79 70 |(device,|gdDevTyp|
|00005d30| 65 29 3b 0d 09 69 66 28 | 69 73 47 72 61 79 29 7b |e);..if(|isGray){|
|00005d40| 0d 09 09 66 6f 72 28 69 | 3d 66 69 72 73 74 45 6e |...for(i|=firstEn|
|00005d50| 74 72 79 3b 69 3c 3d 6c | 61 73 74 45 6e 74 72 79 |try;i<=l|astEntry|
|00005d60| 3b 69 2b 2b 29 7b 0d 09 | 09 09 52 47 42 50 74 72 |;i++){..|..RGBPtr|
|00005d70| 3d 26 74 61 62 6c 65 5b | 69 5d 2e 72 67 62 3b 0d |=&table[|i].rgb;.|
|00005d80| 09 09 09 52 47 42 50 74 | 72 2d 3e 72 65 64 3d 52 |...RGBPt|r->red=R|
|00005d90| 47 42 50 74 72 2d 3e 67 | 72 65 65 6e 3d 52 47 42 |GBPtr->g|reen=RGB|
|00005da0| 50 74 72 2d 3e 62 6c 75 | 65 3d 4c 50 2d 3e 74 61 |Ptr->blu|e=LP->ta|
|00005db0| 62 6c 65 5b 69 5d 2e 72 | 67 62 2e 67 72 65 65 6e |ble[i].r|gb.green|
|00005dc0| 3b 0d 09 09 7d 0d 09 09 | 74 61 62 6c 65 50 74 72 |;...}...|tablePtr|
|00005dd0| 3d 26 74 61 62 6c 65 5b | 66 69 72 73 74 45 6e 74 |=&table[|firstEnt|
|00005de0| 72 79 5d 3b 0d 09 7d 65 | 6c 73 65 20 74 61 62 6c |ry];..}e|lse tabl|
|00005df0| 65 50 74 72 3d 26 4c 50 | 2d 3e 74 61 62 6c 65 5b |ePtr=&LP|->table[|
|00005e00| 66 69 72 73 74 45 6e 74 | 72 79 5d 3b 0d 0d 09 73 |firstEnt|ry];...s|
|00005e10| 77 69 74 63 68 28 28 2a | 64 65 76 69 63 65 29 2d |witch((*|device)-|
|00005e20| 3e 67 64 54 79 70 65 29 | 7b 0d 09 63 61 73 65 20 |>gdType)|{..case |
|00005e30| 66 69 78 65 64 54 79 70 | 65 3a 0d 09 09 70 72 69 |fixedTyp|e:...pri|
|00005e40| 6e 74 66 28 22 4c 6f 61 | 64 4c 75 6d 69 6e 61 6e |ntf("Loa|dLuminan|
|00005e50| 63 65 73 3a 20 74 68 69 | 73 20 64 65 76 69 63 65 |ces: thi|s device|
|00005e60| 20 68 61 73 20 61 20 66 | 69 78 65 64 20 43 4c 55 | has a f|ixed CLU|
|00005e70| 54 2e 5c 6e 22 29 3b 0d | 09 09 72 65 74 75 72 6e |T.\n");.|..return|
|00005e80| 3b 0d 09 63 61 73 65 20 | 63 6c 75 74 54 79 70 65 |;..case |clutType|
|00005e90| 3a 0d 09 09 65 72 72 6f | 72 3d 47 44 53 65 74 45 |:...erro|r=GDSetE|
|00005ea0| 6e 74 72 69 65 73 28 64 | 65 76 69 63 65 2c 66 69 |ntries(d|evice,fi|
|00005eb0| 72 73 74 45 6e 74 72 79 | 2c 6c 61 73 74 45 6e 74 |rstEntry|,lastEnt|
|00005ec0| 72 79 2d 66 69 72 73 74 | 45 6e 74 72 79 2c 74 61 |ry-first|Entry,ta|
|00005ed0| 62 6c 65 50 74 72 29 3b | 0d 09 09 62 72 65 61 6b |blePtr);|...break|
|00005ee0| 3b 0d 09 63 61 73 65 20 | 64 69 72 65 63 74 54 79 |;..case |directTy|
|00005ef0| 70 65 3a 0d 09 09 65 72 | 72 6f 72 3d 47 44 44 69 |pe:...er|ror=GDDi|
|00005f00| 72 65 63 74 53 65 74 45 | 6e 74 72 69 65 73 28 64 |rectSetE|ntries(d|
|00005f10| 65 76 69 63 65 2c 66 69 | 72 73 74 45 6e 74 72 79 |evice,fi|rstEntry|
|00005f20| 2c 6c 61 73 74 45 6e 74 | 72 79 2d 66 69 72 73 74 |,lastEnt|ry-first|
|00005f30| 45 6e 74 72 79 2c 74 61 | 62 6c 65 50 74 72 29 3b |Entry,ta|blePtr);|
|00005f40| 0d 09 09 62 72 65 61 6b | 3b 0d 09 7d 0d 09 69 66 |...break|;..}..if|
|00005f50| 28 65 72 72 6f 72 29 20 | 70 72 69 6e 74 66 28 22 |(error) |printf("|
|00005f60| 5c 30 30 37 4c 6f 61 64 | 4c 75 6d 69 6e 61 6e 63 |\007Load|Luminanc|
|00005f70| 65 73 3a 20 65 72 72 6f | 72 20 25 64 5c 6e 22 2c |es: erro|r %d\n",|
|00005f80| 65 72 72 6f 72 29 3b 0d | 7d 0d 0d 64 6f 75 62 6c |error);.|}..doubl|
|00005f90| 65 20 4c 54 6f 4c 28 4c | 75 6d 69 6e 61 6e 63 65 |e LToL(L|uminance|
|00005fa0| 52 65 63 6f 72 64 20 2a | 4c 50 2c 64 6f 75 62 6c |Record *|LP,doubl|
|00005fb0| 65 20 4c 29 0d 7b 0d 09 | 69 66 28 4c 20 3e 20 4c |e L).{..|if(L > L|
|00005fc0| 50 2d 3e 4c 4d 61 78 29 | 20 72 65 74 75 72 6e 20 |P->LMax)| return |
|00005fd0| 4c 50 2d 3e 4c 4d 61 78 | 3b 0d 09 69 66 28 4c 20 |LP->LMax|;..if(L |
|00005fe0| 3c 20 4c 50 2d 3e 4c 4d | 69 6e 29 20 72 65 74 75 |< LP->LM|in) retu|
|00005ff0| 72 6e 20 4c 50 2d 3e 4c | 4d 69 6e 3b 0d 09 72 65 |rn LP->L|Min;..re|
|00006000| 74 75 72 6e 20 4c 3b 0d | 7d 0d 0d 64 6f 75 62 6c |turn L;.|}..doubl|
|00006010| 65 20 56 54 6f 4c 28 4c | 75 6d 69 6e 61 6e 63 65 |e VToL(L|uminance|
|00006020| 52 65 63 6f 72 64 20 2a | 4c 50 2c 64 6f 75 62 6c |Record *|LP,doubl|
|00006030| 65 20 56 29 0d 2f 2a 0d | 52 65 74 75 72 6e 20 74 |e V)./*.|Return t|
|00006040| 68 65 20 6c 75 6d 69 6e | 61 6e 63 65 20 74 68 61 |he lumin|ance tha|
|00006050| 74 20 77 6f 75 6c 64 20 | 72 65 73 75 6c 74 20 66 |t would |result f|
|00006060| 72 6f 6d 20 61 20 6e 6f | 6d 69 6e 61 6c 20 76 6f |rom a no|minal vo|
|00006070| 6c 74 61 67 65 2e 0d 2a | 2f 0d 7b 0d 09 72 65 74 |ltage..*|/.{..ret|
|00006080| 75 72 6e 20 46 69 78 54 | 6f 44 6f 75 62 6c 65 28 |urn FixT|oDouble(|
|00006090| 5f 56 54 6f 4c 28 4c 50 | 2c 44 6f 75 62 6c 65 54 |_VToL(LP|,DoubleT|
|000060a0| 6f 46 69 78 28 56 29 29 | 29 3b 0d 7d 0d 0d 46 49 |oFix(V))|);.}..FI|
|000060b0| 58 45 44 20 5f 56 54 6f | 4c 28 4c 75 6d 69 6e 61 |XED _VTo|L(Lumina|
|000060c0| 6e 63 65 52 65 63 6f 72 | 64 20 2a 4c 50 2c 46 49 |nceRecor|d *LP,FI|
|000060d0| 58 45 44 20 5f 56 29 0d | 2f 2a 0d 52 65 74 75 72 |XED _V).|/*.Retur|
|000060e0| 6e 20 74 68 65 20 6c 75 | 6d 69 6e 61 6e 63 65 20 |n the lu|minance |
|000060f0| 74 68 61 74 20 77 6f 75 | 6c 64 20 72 65 73 75 6c |that wou|ld resul|
|00006100| 74 20 66 72 6f 6d 20 61 | 20 6e 6f 6d 69 6e 61 6c |t from a| nominal|
|00006110| 20 76 6f 6c 74 61 67 65 | 2e 0d 2a 2f 0d 7b 0d 09 | voltage|..*/.{..|
|00006120| 72 65 67 69 73 74 65 72 | 20 69 6e 74 20 69 3b 0d |register| int i;.|
|00006130| 09 72 65 67 69 73 74 65 | 72 20 6c 75 6d 69 6e 61 |.registe|r lumina|
|00006140| 6e 63 65 54 61 62 6c 65 | 20 2a 4c 54 3b 0d 09 72 |nceTable| *LT;..r|
|00006150| 65 67 69 73 74 65 72 20 | 46 49 58 45 44 20 5f 64 |egister |FIXED _d|
|00006160| 69 3b 0d 09 64 6f 75 62 | 6c 65 20 4c 46 2c 56 46 |i;..doub|le LF,VF|
|00006170| 3b 0d 09 0d 09 4c 54 3d | 26 4c 50 2d 3e 4c 3b 0d |;....LT=|&LP->L;.|
|00006180| 09 69 66 28 4c 54 2d 3e | 65 78 69 73 74 73 3d 3d |.if(LT->|exists==|
|00006190| 6c 75 6d 69 6e 61 6e 63 | 65 53 65 74 29 7b 0d 09 |luminanc|eSet){..|
|000061a0| 09 5f 64 69 3d 46 69 78 | 44 69 76 28 5f 56 2d 4c |._di=Fix|Div(_V-L|
|000061b0| 54 2d 3e 5f 56 4d 69 6e | 2c 4c 54 2d 3e 5f 64 56 |T->_VMin|,LT->_dV|
|000061c0| 29 3b 0d 09 09 69 3d 46 | 69 78 54 6f 4c 6f 6e 67 |);...i=F|ixToLong|
|000061d0| 28 5f 64 69 29 3b 0d 09 | 09 5f 64 69 20 2d 3d 20 |(_di);..|._di -= |
|000061e0| 4c 6f 6e 67 54 6f 46 69 | 78 28 69 29 3b 0d 09 09 |LongToFi|x(i);...|
|000061f0| 69 66 28 69 3c 30 29 72 | 65 74 75 72 6e 20 4c 54 |if(i<0)r|eturn LT|
|00006200| 2d 3e 5f 4c 75 5b 30 5d | 3b 0d 09 09 69 66 28 69 |->_Lu[0]|;...if(i|
|00006210| 3e 3d 4c 55 4d 49 4e 41 | 4e 43 45 53 5f 49 4e 5f |>=LUMINA|NCES_IN_|
|00006220| 54 41 42 4c 45 2d 31 29 | 72 65 74 75 72 6e 20 4c |TABLE-1)|return L|
|00006230| 54 2d 3e 5f 4c 75 5b 4c | 55 4d 49 4e 41 4e 43 45 |T->_Lu[L|UMINANCE|
|00006240| 53 5f 49 4e 5f 54 41 42 | 4c 45 2d 31 5d 3b 0d 09 |S_IN_TAB|LE-1];..|
|00006250| 09 72 65 74 75 72 6e 20 | 4c 54 2d 3e 5f 4c 75 5b |.return |LT->_Lu[|
|00006260| 69 5d 2b 46 69 78 4d 75 | 6c 28 5f 64 69 2c 4c 54 |i]+FixMu|l(_di,LT|
|00006270| 2d 3e 5f 4c 75 5b 69 2b | 31 5d 2d 4c 54 2d 3e 5f |->_Lu[i+|1]-LT->_|
|00006280| 4c 75 5b 69 5d 29 3b 0d | 09 7d 0d 09 56 46 3d 46 |Lu[i]);.|.}..VF=F|
|00006290| 69 78 54 6f 44 6f 75 62 | 6c 65 28 5f 56 29 3b 0d |ixToDoub|le(_V);.|
|000062a0| 09 69 66 28 4c 50 2d 3e | 70 6f 77 65 72 45 72 72 |.if(LP->|powerErr|
|000062b0| 6f 72 20 3c 20 32 2e 30 | 2a 4c 50 2d 3e 70 6f 6c |or < 2.0|*LP->pol|
|000062c0| 79 6e 6f 6d 69 61 6c 45 | 72 72 6f 72 29 20 4c 46 |ynomialE|rror) LF|
|000062d0| 3d 56 54 6f 4c 50 6f 77 | 65 72 28 4c 50 2c 56 46 |=VToLPow|er(LP,VF|
|000062e0| 29 3b 0d 09 65 6c 73 65 | 20 4c 46 3d 56 54 6f 4c |);..else| LF=VToL|
|000062f0| 50 6f 6c 79 6e 6f 6d 69 | 61 6c 28 4c 50 2c 56 46 |Polynomi|al(LP,VF|
|00006300| 29 3b 0d 09 72 65 74 75 | 72 6e 20 44 6f 75 62 6c |);..retu|rn Doubl|
|00006310| 65 54 6f 46 69 78 28 4c | 46 29 3b 0d 7d 0d 0d 64 |eToFix(L|F);.}..d|
|00006320| 6f 75 62 6c 65 20 4c 54 | 6f 56 28 4c 75 6d 69 6e |ouble LT|oV(Lumin|
|00006330| 61 6e 63 65 52 65 63 6f | 72 64 20 2a 4c 50 2c 64 |anceReco|rd *LP,d|
|00006340| 6f 75 62 6c 65 20 4c 29 | 0d 7b 0d 09 72 65 74 75 |ouble L)|.{..retu|
|00006350| 72 6e 20 46 69 78 54 6f | 44 6f 75 62 6c 65 28 5f |rn FixTo|Double(_|
|00006360| 4c 54 6f 56 28 4c 50 2c | 44 6f 75 62 6c 65 54 6f |LToV(LP,|DoubleTo|
|00006370| 46 69 78 28 4c 29 29 29 | 3b 0d 7d 0d 0d 46 49 58 |Fix(L)))|;.}..FIX|
|00006380| 45 44 20 5f 4c 54 6f 56 | 28 4c 75 6d 69 6e 61 6e |ED _LToV|(Luminan|
|00006390| 63 65 52 65 63 6f 72 64 | 20 2a 4c 50 2c 46 49 58 |ceRecord| *LP,FIX|
|000063a0| 45 44 20 5f 4c 75 29 0d | 2f 2a 0d 4e 65 77 2c 20 |ED _Lu).|/*.New, |
|000063b0| 66 61 73 74 65 72 20 76 | 65 72 73 69 6f 6e 20 75 |faster v|ersion u|
|000063c0| 73 65 73 20 61 20 74 61 | 62 75 6c 61 74 65 64 20 |ses a ta|bulated |
|000063d0| 76 65 72 73 69 6f 6e 20 | 6f 66 20 74 68 65 20 67 |version |of the g|
|000063e0| 61 6d 6d 61 20 66 75 6e | 63 74 69 6f 6e 20 56 54 |amma fun|ction VT|
|000063f0| 6f 4c 28 29 2e 20 54 68 | 69 73 0d 72 65 70 6c 61 |oL(). Th|is.repla|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.